一个简单c语言程序~~望高手帮助!

来源:百度知道 编辑:UC知道 时间:2024/05/30 22:33:45
已知某班N(〈=50)名学生进行了高数、英语和C语言等3门课考试,将3门课的成绩以及计算3门课的总分存放于一个二维数组中,将学生姓名存放在另一个二维字符数组中,按总分(由高到低)排序(注意:学生姓名也应该按总分排序)并输出排序结果(序号、姓名及总分)。
这就是原题了~~我也没办法了~~拜托大家了

#include<stdio.h>
#include<string.h>

int main()
{
int n,i,j,t,score[51][4];//score[i][0]里存第一门课成绩,score[i][3]里面存总分
char name[51][20],s[20];
printf("Input n:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s%d%d%d%d",name[i],&score[i][0],&score[i][1],&score[i][2],&score[i][3]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(score[i][3]<score[j][3])
{
t=score[i][0];
score[i][0]=score[j][0];
score[j][0]=t;
t=score[i][1];
score[i][1]=score[j][1];
score[j][1]=t;
t=score[i][2];
score[i][2]=score[j][2];
score[j][2]=t;
t=score[i][3];
score[i][3]=score[j][3];
score[j][3]=t;
strcpy(s,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],s);
}
}
}
for(i=0;i<n;i++)
{