| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1907 人关注过本帖
标题:在三个学生中输出平均成绩最高的学生信息,请问一下我程序的问题在哪里
取消只看楼主 加入收藏
yangtanzheng
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2019-7-1
结帖率:66.67%
收藏
已结贴  问题点数:5 回复次数:1 
在三个学生中输出平均成绩最高的学生信息,请问一下我程序的问题在哪里
#include <stdio.h>
struct stu
{
    int num;
    char name[10];
    float score[3];
    float aver;
};
void input (struct stu st1[])
{
    int i;
    printf("please three stu number:\n");
    for(i=0;i<3;i++)
    {
        scanf("%d,%s,%f,%f,%f",&st1[i].num,&st1[i].name,&st1[i].score[0],&st1[i].score[1],&st1[i].score[2]);
        st1[i].aver=(st1[i].score[0]+st1[i].score[1]+st1[i].score[2])/3;
    }
}
void max(struct stu st2[])
{   

    struct stu p;
    int i,j;
    input(st2);
    for(j=0;j<2;j++)
    {
        for(i=0;i<3-j-1;i++)
        {
            if(st2[i].aver<st2[i+1].aver)
            {
                p=st2[i];
                st2[i]=st2[i+1];
                st2[i+1]=p;
            }
        }
    }
    printf("%d,%s,%f,%f,%f",st2[0].num,st2[0].name,st2[0].score[0],st2[0].score[1],st2[0].score[2]);   
}
int main()
{
    struct stu st[3],*p=st;
    max(p);
    return 0;
搜索更多相关主题的帖子: 学生 struct stu int score 
2019-07-19 17:26
yangtanzheng
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2019-7-1
收藏
得分:0 
回复 3楼 rjsp
我明白了 谢谢大佬
2019-07-22 22:03
快速回复:在三个学生中输出平均成绩最高的学生信息,请问一下我程序的问题在哪里 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015771 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved