参考代码:
#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 人评分
数对 (C语言代码)浏览:702 |
图形输出 (C语言代码)浏览:1387 |
复数求和 (C语言代码)浏览:926 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:562 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:573 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:527 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:526 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:720 |
逆反的01串 (C语言代码)浏览:1444 |
C语言程序设计教程(第三版)课后习题5.5 (Java代码)浏览:540 |