parent
d6ef16cef0
commit
5c8494e12d
@ -0,0 +1,103 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
void input();
|
||||
void select1();
|
||||
void order();
|
||||
void output();
|
||||
int sum=2;
|
||||
int flag;
|
||||
struct stu
|
||||
{
|
||||
int Id;
|
||||
int clas;
|
||||
char name[100];
|
||||
float score1;
|
||||
float score2;
|
||||
float score3;
|
||||
float score;
|
||||
}stu[100]={{10001,11,"Zhang",99.5,88.5,89.5,277.5},
|
||||
{10002,12,"Yang",77.9,56.5,87.5,221.9},
|
||||
{10003,11,"Liang",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("%s",&stu[sum].name);
|
||||
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;
|
||||
select1();
|
||||
}
|
||||
void select1()
|
||||
{
|
||||
int k;
|
||||
for(int i=0;i<=sum-1;i++)
|
||||
{
|
||||
if(stu[i].Id==flag)
|
||||
{
|
||||
k=i;
|
||||
}
|
||||
}
|
||||
for(int j=k;j<=sum;j++)
|
||||
{
|
||||
stu[j]=stu[j+1];
|
||||
}
|
||||
sum=sum-1;
|
||||
}
|
||||
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()
|
||||
{
|
||||
printf("%d %d %s %.1f %.1f %.1f",stu[0].clas,stu[0].Id,stu[0].name,stu[0].score1,stu[0].score2,stu[0].score3);
|
||||
for(int i=1;i<=sum;i++)
|
||||
{
|
||||
if(stu[i].clas==stu[i-1].clas)
|
||||
{
|
||||
printf(" modified");
|
||||
printf("\n");
|
||||
printf(" %d %s %.1f %.1f %.1f",stu[i].Id,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n");
|
||||
printf("%d %d %s %.1f %.1f %.1f \n",stu[i].clas,stu[i].Id,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue