KKKevin
|
分享:
▲
▼
问题二 #include<stdio.h>
int main(){ freopen("路径(档名).副档名","r",stdin); freopen("路径(档名).副档名","w",stdout); int num[6],grade[6][3],sum[6],ave[6],sta[6],t[6][2],i,j,k; char name[6][50]; for(i = 0;i < 6;i++){ scanf("%d %s %d %d %d", &num, &name, &grade[0], &grade[1], &grade[2]); sum = grade[0]+grade[1]+grade[2]; ave = sum/3; sta = 0; t[0] = sum; t[1] = i; } for(i = 6;i > 0;i--) for(j = 0;j < i-1;j++) if(t[j][0] > t[j+1][0]){ k = t[j][0]; t[j][0] = t[j+1][0]; t[j+1][0] = k; k = t[j][1]; t[j][1] = t[j+1][1]; t[j+1][1] = k; } for(i = 5;i >= 0;i--) sta[t[1]] = 6-i; for(i = 0;i < 6;i++) printf("%d %d %d\n",sum,ave,sta); return 0; } ps:输出格式及档名请自行变更
|