parent
cebbc7dc54
commit
46a17d5f2d
@ -0,0 +1,64 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
struct stu {
|
||||
char num[6];
|
||||
char class[3];
|
||||
char name[6];
|
||||
float grade1;
|
||||
float grade2;
|
||||
float grade3;
|
||||
float grade;
|
||||
}s[10],ss;
|
||||
int main()
|
||||
{
|
||||
strcpy(s[0].num,"10001");strcpy(s[0].class,"11");strcpy(s[0].name,"Zhang");s[0].grade1=99.5;s[0].grade2=88.5;s[0].grade3=89.5;s[0].grade=s[0].grade1+s[0].grade2+s[0].grade3;
|
||||
strcpy(s[1].num,"10002");strcpy(s[1].class,"12");strcpy(s[1].name,"Yang");s[1].grade1=77.9;s[1].grade2=56.5;s[1].grade3=87.5;s[1].grade=s[1].grade1+s[1].grade2+s[1].grade3;
|
||||
strcpy(s[2].num,"10003");strcpy(s[2].class,"11");strcpy(s[2].name,"Liang");s[2].grade1=92.5;s[2].grade2=99.0;s[2].grade3=60.5;s[2].grade=s[2].grade1+s[2].grade2+s[2].grade3;
|
||||
scanf("%s%s%s%f%f%f",s[3].num,s[3].class,s[3].name,&s[3].grade1,&s[3].grade2,&s[3].grade3);
|
||||
s[3].grade=s[3].grade1+s[3].grade2+s[3].grade3;
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
if(strcmp(s[i].num,s[3].num)==0)
|
||||
{
|
||||
s[i]=s[3];
|
||||
}
|
||||
}
|
||||
for(int i=0;i<2;i++)
|
||||
{
|
||||
for(int j=i+1;j<3;j++)
|
||||
{
|
||||
if(strcmp(s[i].class,s[j].class)>0)
|
||||
{
|
||||
ss=s[i];
|
||||
s[i]=s[j];
|
||||
s[j]=ss;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;strcmp(s[i].class,s[0].class)==0;i++)
|
||||
{
|
||||
for(int j=i+1;strcmp(s[j].class,s[0].class)==0;j++)
|
||||
{
|
||||
if(s[i].grade<s[j].grade)
|
||||
{
|
||||
ss=s[i];
|
||||
s[i]=s[j];
|
||||
s[j]=ss;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for(int i=1;strcmp(s[i].class,s[0].class)==0;i++)
|
||||
{
|
||||
strcpy(s[i].class," ");
|
||||
}
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
printf("%s %s %s %.1f %.1f %.1f",s[i].class,s[i].num,s[i].name,s[i].grade1,s[i].grade2,s[i].grade3);
|
||||
if(strcmp(s[3].num,s[i].num)==0)
|
||||
printf(" modified\n");
|
||||
else
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue