查看單個文章
舊 2002-12-12, 05:43 PM   #8 (permalink)
小布
榮譽勳章

勳章總數
UID -
在線等級:
文章: n/a
精華:
預設

以下程式碼
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;

改成

sum1 = grade[0][0] + grade[0][1] + grade[0][2];
ave1 =(float) sum1/3;
sum2 = grade[1][0] + grade[1][1] + grade[1][2];
ave2 = (float)sum2/3;
sum3 = grade[2][0] + grade[2][1] + grade[2][2];
ave3 = (float)sum3/3;
sum4 = grade[3][0] + grade[3][1] + grade[3][2];
ave4 = (float)sum4/3;
sum5 = grade[4][0] + grade[4][1] + grade[4][2];
ave5 = (float)sum5/3;
試試看
記得最後要printf的時候,要把%d改成%f應該就可以了吧
 
送花文章: 0, 收花文章: 0 篇, 收花: 0 次
回覆時引用此帖