参考代码:
#include<iostream> using namespace std; typedef struct{ char x[10]; char name[10]; double a; double b; double c; double ave; }student; student *input(){ student *s=new student; cin>>s->x; cin>>s->name; cin>>s->a; cin>>s->b; cin>>s->c; s->ave=(s->a+s->b+s->c)/3; return s; } int main() { int n; cin>>n; student *s[n]; for(int i=0;i<n;i++){ s[i]=input(); } double t1=0,t2=0,t3=0,Max=0; int m; for(int i=0;i<n;i++){ t1+=s[i]->a; t2+=s[i]->b; t3+=s[i]->c; if(s[i]->ave>Max){ Max=s[i]->ave; m=i; } } t1=t1/n;t2=t2/n;t3=t3/n; cout<<t1<<" "<<t2<<" "<<t3<<endl; cout<<s[m]->x<<" "<<s[m]->name<<" "<<s[m]->a<<" "<<s[m]->b<<" "<<s[m]->c; return 0; }
0.0分
3 人评分
字符串输入输出函数 (Java代码)浏览:1498 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:553 |
十->二进制转换 (C语言代码)浏览:1330 |
拆分位数 (C语言代码)浏览:1361 |
剪刀石头布 (C语言代码)浏览:1792 |
WU-整除问题 (C++代码)浏览:648 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:672 |
图形输出 (C语言代码)浏览:1019 |
简单的a+b (C语言代码)浏览:444 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:420 |