#include <stdio.h>
void main()
{
int num[6][5],po[6];
int sum1,sum2,i,j,temp;
printf("\1: 請輸入成績 \n");
for ( i = 0; i < 5; i++ )
for ( j = 0; j < 3; j++ )
scanf("%d",&num[i][j]);
for ( i = 0; i < 5; i++ )
{
sum1 = 0;
for ( j = 0; j < 3; j++ )
sum1 += num[i][j];
num[i][3] = sum1 / 3;
}
for ( i = 0; i < 5; i++ )
{
po[i] = num[i][3];
}
for ( i = 0; i < 4; i++ )
for ( j = i + 1; j < 5; j++ )
if ( po[i] < po[j] )
{
temp = po[i];
po[i] = po[j];
po[j] = temp;
}
for ( i = 0; i < 5; i++ )
{
if ( num[i][3] == po[0] )
num[i][4] = 1;
else if ( num[i][3] == po[1] )
num[i][4] = 2;
else if ( num[i][3] == po[2] )
num[i][4] = 3;
else if ( num[i][3] == po[3] )
num[i][4] = 4;
else if ( num[i][3] == po[4] )
num[i][4] = 5;
}
for ( j = 0; j < 4; j++ )
{
sum2 = 0;
for ( i = 0; i < 5; i++ )
sum2 += num[i][j];
num[5][j] = sum2 / 5;
}
num[5][4]=0;
for ( i = 0; i < 6; i++ )
printf("\2:%d %d %d %d %d \n",num[i][0],num[i][1],num[i][2],num[i][3],num[i][4]);
}
==============================================
<--這是同學滴答案...可是我不想抄襲~~我滴問題只剩下如何把ave1~5一起丟進陣列裡= =....排名要怎ㄇ讓他排出來(也是丟到陣列裡讓程式自己排名次)
|