#include
#define snum 5
int tot[snum]={0}, rank[snum]={0};
int mrank()
{
int i,j;
rank[0] = 1;
for ( i = 1; i < snum; i++ )
rank[i] = 1;
for ( i = 1; i < snum; i++ ){
for( j=0; j < i; j++ ){
if ( tot[i] > tot[j] ){
//rank[i] = rank[j];
rank[j]++;
} else {
rank[i]++;
}
}
}
return 0;
}
void main( ){
int kuk[snum], eng[snum], mat[snum], k;
float ava[snum]={0};
char name[snum][10];
int i=0;
for(i=0; i < snum; i++) {
printf("성명:");
scanf("%s", name[i]);
printf("국어:");
scanf("%d", &kuk[i]);
printf("영어:");
scanf("%d", &eng[i]);
printf("수학:");
scanf("%d", &mat[i]);
tot[i] = kuk[i] + eng[i] + mat[i];
ava[i] = tot[i] / 3.0f; } k = mrank();
printf("----------------------------------------------------------------------");
printf("성명 국어 영어 수학 총점 평균 순위");
printf("----------------------------------------------------------------------");
for(i=0; i < snum; i++) {
printf("%-10s %-3d %-3d %-3d %-3d %-7.2f %d", name[i], kuk[i], eng[i],mat[i],tot[i], ava[i],rank[i]);
}
printf("----------------------------------------------------------------------");
}