Just look at the code,that's OK;
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
struct student
{
char name[20];
int total;
int chinese;
int math;
}a[1005];
bool cmp(student x,student y)
{
if(x.total>y.total)
return 1;
else if(x.total==y.total)
{
if(x.chinese>y.chinese)
return 1;
else if(x.chinese==y.chinese)
{
if(x.math>y.math)
return 1;
}
}
return 0;
}
int main()
{
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d %d %d",a[i].name,&a[i].total,&a[i].chinese,&a[i].math);
}
sort(a,a+n,cmp);
for(i=0;i<n;i++)
{
printf("%s\n",a[i].name);
}
return 0;
}