解题思路:
注意事项:
参考代码:
#include<stdio.h> #include<stdlib.h> typedef struct student { char id[10]; char name[10]; int score1; int score2; int score3; int s; struct student *next; }Stu; int main() { int n; scanf("%d",&n); int i,sum1=0,sum2=0,sum3=0; Stu *head,*end,*pnew,*p,*max; head=(Stu*)malloc(sizeof(Stu)); head->next=NULL; end=head; for(i=0;i<n;i++) { pnew=(Stu*)malloc(sizeof(Stu)); scanf("%s%s%d%d%d",&pnew->id,&pnew->name,&pnew->score1,&pnew->score2,&pnew->score3); pnew->s=pnew->score1+pnew->score2+pnew->score3; pnew->next=NULL; end->next=pnew; end=pnew; sum1+=pnew->score1; sum2+=pnew->score2; sum3+=pnew->score3; } max=head; for(p=head->next;p!=NULL;p=p->next) { if(p->s>max->s) max=p; } printf("%d %d %d\n",sum1/n,sum2/n,sum3/n); printf("%s %s %d %d %d",max->id,max->name,max->score1,max->score2,max->score3); return 0; free(head); free(pnew); free(p); free(max); }
0.0分
0 人评分
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C++代码)(手动优化一下计算)浏览:1282 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:666 |
用筛法求之N内的素数。 (C语言代码)浏览:1237 |
众数问题 (C语言代码)浏览:829 |
WU-陶陶摘苹果2 (C++代码)浏览:972 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:879 |
1642题解浏览:714 |
打印十字图 (C语言代码)浏览:2708 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:504 |
字符串输入输出函数 (C语言代码)浏览:2487 |