請問?C語言的這裡要怎ㄇ寫下去..???
各位大大~~我又來請教各位了.....小弟愚昧~~~請多多見諒....QQ"........
這個程式5ㄍ學生比較數學.英文.電算的成績.跟比較名次...5ㄍ人我不知道怎ㄇ比~"~??還有%d 怎ㄇ讓他顯示出來的是小數點~~比較出來的成績怎ㄇ把他丟到陣列去然後一起顯示出來~"~??
#include<stdio.h>
void main()
{
int grade[5][3] = {
{80,88,93},
{76,74,81},
{58,66,64},
{63,73,71},
{77,92,90}};
int i , j , sum1,sum2,sum3,sum4,sum5;
int ave1,ave2,ave3,ave4,ave5;
for (i=0;i<5;i++)
{
for(j=0;j<3;j++)
{
printf("%-3d",grade[i][j]);
}
printf("\n");
}
sum1 = grade[0][0] + grade[0][1] + grade[0][2];
ave1 = sum1/3;
sum2 = grade[1][0] + grade[1][1] + grade[1][2];
ave2 = sum2/3;
sum3 = grade[2][0] + grade[2][1] + grade[2][2];
ave3 = sum3/3;
sum4 = grade[3][0] + grade[3][1] + grade[3][2];
ave4 = sum4/3;
sum5 = grade[4][0] + grade[4][1] + grade[4][2];
ave5 = sum5/3;
printf("The first student's average is ===>%d \n",ave1);
printf("The second student's average is ===>%d \n",ave2);
printf("The third student's average is ===>%d \n",ave3);
printf("The fourth student's average is ===>%d \n",ave4);
printf("The fifth student's average is ===>%d \n",ave5);
{
int sum6,sum7,sum8;
int ave6,ave7,ave8;
sum6 = grade[0][0] + grade[1][0] + grade[2][0] + grade[3][0] + grade[4][0];
ave6 = sum6/5;
sum7 = grade[0][1] + grade[1][1] + grade[2][1] + grade[3][1] + grade[4][1];
ave7 = sum7/5;
sum8 = grade[0][2] + grade[1][2] + grade[2][2] + grade[3][2] + grade[4][2];
ave8 = sum8/5;
printf("The all class's Math average is ===>%d \n",ave6);
printf("The all class's English average is ===>%d \n",ave7);
printf("The all class's Electronics average is ===>%d \n",ave8);
}
}
|