解题思路:

                    


                        定义不同的变量进行对比,最后输出

注意事项:

参考代码:


            

                        #include<iostream>

                        #include<string>                         //string类
                        using namespace std;
                        struct stu{
                                     int Y,S,E,Z;                    //三门成绩,Z是总分
                                     string name;
                                     char glade;                     //学号
                                            };

                                 int main()
                                 {
                                       int Y,S,E;                          //三个变量为三门学课的成绩平均分
                                       int m,n,i;
                                       Y=S=E=i=0;
                                       cin>>m;
                                       stu x_s[m];                         //创建输入次数大小的结构体
                                        n=m;                                //保存一下大小
                                        while(m--)
                                         {
                                                cin>>x_s[i].glade;
                                                cin>>x_s[i].name;
                                                cin>>x_s[i].Y;
                                                cin>>x_s[i].S;
                                                cin>>x_s[i].E;
                                                Y+=x_s[i].Y;
                                                S+=x_s[i].S;
                                                E+=x_s[i].E;
                                                x_s[i].Z=x_s[i].Y+x_s[i].S+x_s[i].E;    //Z是总分
                                                i++;
                                          }
                                         int G=x_s[0].Z;                                //比较一下然后取出来
                                         for(i=1;i<n;i++)
                                                if(G<x_s[i].Z)
                                                            G=x_s[i].Z;
                                         Y/=n;            //平均成绩
                                         S/=n;
                                         E/=n;
                                         cout<<Y<<" "<<S<<" "<<E<<endl;
                                         for(i=0;i<n;i++)
                                            if(G==x_s[i].Z)                          //取出来和结构体比较          
                                                cout<<x_s[i].glade<<" "<<x_s[i].name<<" "<<x_s[i].Y<<" "<<x_s[i].S<<" "<<x_s[i].E<<endl;

                                    return 0;
                                  }


点赞(0)
 

0.0分

0 人评分

C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:

一点编程也不会写的:零基础C语言学练课程

解决困扰你多年的C语言疑难杂症特性的C语言进阶课程

从零到写出一个爬虫的Python编程课程

只会语法写不出代码?手把手带你写100个编程真题的编程百练课程

信息学奥赛或C++选手的 必学C++课程

蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程

手把手讲解近五年真题的蓝桥杯辅导课程

评论列表 共有 1 条评论

wanghuimin 4年前 回复TA
用到数据结构了吗?