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.
56 lines
1.3 KiB
56 lines
1.3 KiB
1 week ago
|
#include <stdio.h>
|
||
|
struct stu {
|
||
|
int num;
|
||
|
int class;
|
||
|
float grade1;
|
||
|
float grade2;
|
||
|
float grade3;
|
||
|
float grade;
|
||
|
}s[10],ss;
|
||
|
int main()
|
||
|
{
|
||
|
s[0].num=10001;s[0].class=11;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;
|
||
|
s[1].num=10002;s[1].class=12;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;
|
||
|
s[2].num=10003;s[2].class=11;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("%d%d%f%f%f",&s[3].num,&s[3].class,&s[3].grade1,&s[3].grade2,&s[3].grade3);
|
||
|
int t=s[3].num;
|
||
|
s[3].grade=s[3].grade1+s[3].grade2+s[3].grade3;
|
||
|
for(int i=0;i<3;i++)
|
||
|
{
|
||
|
ss=s[i];
|
||
|
for(int j=i+1;j<4;j++)
|
||
|
{
|
||
|
if(s[i].class>s[j].class)
|
||
|
{
|
||
|
ss=s[i];
|
||
|
s[i]=s[j];
|
||
|
s[j]=ss;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
for(int i=0;s[i].class==s[0].class;i++)
|
||
|
{
|
||
|
ss=s[i];
|
||
|
for(int j=i+1;s[j].class==s[0].class;j++)
|
||
|
{
|
||
|
if(s[i].grade<s[j].grade)
|
||
|
{
|
||
|
ss=s[i];
|
||
|
s[i]=s[j];
|
||
|
s[j]=ss;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
for(int i=0;i<4;i++)
|
||
|
{
|
||
|
printf("%d %d %.1f %.1f %.1f",s[i].num,s[i].class,s[i].grade1,s[i].grade2,s[i].grade3);
|
||
|
if(t==s[i].num)
|
||
|
printf(" inserted\n");
|
||
|
else
|
||
|
printf("\n");
|
||
|
}
|
||
|
return 0;
|
||
|
}
|