一个简单c语言程序~~望高手帮助!
来源:百度知道 编辑:UC知道 时间:2024/05/30 22:33:45
这就是原题了~~我也没办法了~~拜托大家了
#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++)
{