You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1020 B
34 lines
1020 B
#include<stdio.h>
|
|
#include<string.h>
|
|
#define N 3
|
|
struct Student
|
|
{char xuehao[10];
|
|
int banji;
|
|
char name[20];
|
|
float grade1;
|
|
float grade2;
|
|
float grade3;
|
|
};
|
|
int main()
|
|
{struct Student st[N]={{"10001",11,"Zhang",99.5,88.5,89.5},
|
|
{"10002",12,"Yang",77.9,56.5,87.5},
|
|
{"10003",11,"Liang",92.5,99.0,60.5}};
|
|
struct Student a,b;
|
|
scanf("%s%d%s%f%f%f",&a.xuehao,&a.banji,a.name,&a.grade1,&a.grade2,&a.grade3);
|
|
int i,j,k,l;
|
|
for(i=0;i<N;i++)if(strcmp(a.xuehao,st[i].xuehao)==0)st[i]=a;
|
|
for(j=0;j<N-1;j++)
|
|
{for(l=j+1;l<N;l++)
|
|
if(st[j].banji>st[l].banji){b=st[j];st[j]=st[l];st[l]=b;}}
|
|
printf("%d %s %s %.1f %.1f %.1f\n",st[0].banji,st[0].xuehao,st[0].name,st[0].grade1,st[0].grade2,st[0].grade3);
|
|
for(k=1;k<N;k++)
|
|
{
|
|
if(st[k].banji==st[k-1].banji)
|
|
printf(" %s %s %.1f %.1f %.1f\n",st[k].xuehao,st[k].name,st[k].grade1,st[k].grade2,st[k].grade3);
|
|
else printf("%d %s %s %.1f %.1f %.1f\n",st[k].banji,st[k].xuehao,st[k].name,st[k].grade1,st[k].grade2,st[k].grade3);
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
|