文章
145
粉丝
217
获赞
21
访问
84.3k
#include <stdio.h>
typedef struct{
char name[20];
int Math,Eng,Ch;
int sum;
}Student;
//排序
void Sort(Student s[],int n)
{
int i,j;
Student t;
for(i = 0; i < n-1; i++)
for(j = 1; j < n-i; j++)
{
if(s[j].sum > s[j-1].sum)
{
t = s[j];
s[j] = s[j-1];
s[j-1] = t;
}
else if(s[j].sum == s[j-1].sum)
{
if(s[j].Ch > s[j-1].Ch)
{
t = s[j];
s[j] = s[j-1];
s[j-1] = t;
}
else if(s[j].Ch == s[j-1].Ch)
{
if(s[j].Math > s[j-1].Math)
{
t = s[j];
s[j] = s[j-1];
s[j-1] = t;
}
else if(s[j].Math == s[j-1].Math)
{
if(s[j].Eng > s[j-1].Eng)
{
t = s[j];
s[j] = s[j-1];
s[j-1] = t;
}
}
}
}
}
}
int main()
{
Student s[1000];
int n,i;
scanf("%d",&n);
for(i = 0; i < n; i++)
{
scanf("%s %d %d %d",s[i].name,&s[i].Ch,&s[i].Math,&s[i].E...
登录后发布评论
暂无评论,来抢沙发