荒天帝


私信TA

用户名:ljhabc

访问量:3106

签 名:

等  级
排  名 425
经  验 4778
参赛次数 1
文章发表 126
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:简单模拟
注意事项:说30行是因为我的注释占了三行不算。
参考代码:

#include<bits/stdc++.h>

using namespace std;

int n,sum[3],maxn,cnt;

typedef struct stde{

   string nu;

   string na;

   int sc[3];

}stu;

int main(){

   cin>>n;

   stu st[n];

   //输入

   for(int i=0;i<n;i++){

       cin>>st[i].nu>>st[i].na;

       for(int j=0;j<3;j++)

           cin>>st[i].sc[j];

   }

   //处理

   for(int i=0;i<n;i++){

       for(int j=0;j<3;j++){

           if(st[i].sc[j]>maxn) maxn=st[i].sc[j],cnt=i;

           sum[j] +=st[i].sc[j];//每科成绩

       }

   }

   //输出

   for(int i=0;i<3;i++)//平均成绩输出

       cout<<sum[i]/n<<" ";

   cout<<endl;

   cout<<st[cnt].nu<<" "<<st[cnt].na<<" "; //对象输出

   for(int i=0;i<3;i++)

       cout<<st[cnt].sc[i]<<" ";

   return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区