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.
74 lines
1.3 KiB
74 lines
1.3 KiB
#include <stdio.h>
|
|
#include <time.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
void input();
|
|
void order();
|
|
void output();
|
|
int sum=2;
|
|
int flag;
|
|
struct stu
|
|
{
|
|
int Id;
|
|
int clas;
|
|
float score1;
|
|
float score2;
|
|
float score3;
|
|
float score;
|
|
}stu[100]={{1001,11,99.5,88.5,89.5,277.5},
|
|
{1002,12,77.9,56.5,87.5,221.9},
|
|
{1003,11,92.5,99.0,60.5,252}};
|
|
int main()
|
|
{
|
|
while(1)
|
|
{
|
|
input();
|
|
order();
|
|
output();
|
|
}
|
|
}
|
|
void input()
|
|
{
|
|
sum=sum+1;
|
|
scanf("%d",&stu[sum].Id);
|
|
flag=stu[sum].Id;
|
|
scanf("%d",&stu[sum].clas);
|
|
scanf("%f",&stu[sum].score1);
|
|
scanf("%f",&stu[sum].score2);
|
|
scanf("%f",&stu[sum].score3);
|
|
stu[sum].score=stu[sum].score3+stu[sum].score2+stu[sum].score1;
|
|
}
|
|
void order()
|
|
{
|
|
for(int i=0;i<=sum;i++)
|
|
{
|
|
for(int j=i;j<=sum;j++)
|
|
{
|
|
if(stu[i].clas>stu[j].clas)
|
|
{
|
|
stu[sum+1]=stu[i];
|
|
stu[i]=stu[j];
|
|
stu[j]=stu[sum+1];
|
|
}
|
|
else if(stu[i].clas==stu[j].clas)
|
|
{
|
|
if(stu[i].score<stu[j].score)
|
|
{
|
|
stu[sum+1]=stu[i];
|
|
stu[i]=stu[j];
|
|
stu[j]=stu[sum+1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void output()
|
|
{
|
|
for(int i=0;i<=sum;i++)
|
|
{
|
|
printf("%d %d %.1f %.1f %.1f",stu[i].Id,stu[i].clas,stu[i].score1,stu[i].score2,stu[i].score3);
|
|
if(flag==stu[i].Id)printf(" inserted");
|
|
printf("\n");
|
|
}
|
|
}
|