文章
28
粉丝
230
获赞
23
访问
241.9k
#include <stdio.h>
#include <stdlib.h>
typedef struct Stu
{
int Number;
char Class[20];
char name[20];
double grade1;
double grade2;
double grade3;
}Stu;
double Avg(Stu arr[],int num);//函数声明
int main(int argc, char const *argv[])
{
int i = 0 ;
int N;
Stu A[1000]={0};
scanf("%d",&N);
while(N!=0){
scanf("%d %s %s %lf %lf %lf",&A[i].Number,&A[i].Class,&A[i].name,&A[i].grade1,&A[i].grade2,&A[i].grade3);
i++;
N--;
}
for (int j = 0; j < i; ++j)
{
printf("%s ",A[j].name);
double AVG=Avg(A,j);
printf("%.1f\n",AVG);
}
int key,k;
k=key=0;
int MAX=(A[k].grade1+A[k].grade2+A[k].grade3);
for (k = 1; k < i; ++k)
{
int max = (A[k].grade1+A[k].grade2+A[k].grade3);
if (MAX<max)
{
MAX=max;
key=k;
}
}
printf("%d %s %s %.1f %.1f %.1f %.1f\n",A[key].Number,A[key].Class,A[key].name,A[key].grade1,A[key].grade2,A[key].grade3,Avg(A,key) );
return 0;
}
...
登录后发布评论
暂无评论,来抢沙发