可是我不知道我原本的highest輸出為何是錯的(編譯器為dev c++)
#include <stdio.h>
#include <stdlib.h>
#define N 3
int main() {
double sum = 0;
double avg;
int score[N];
int i;
score[i];
for(i=0;i<N;i++){
scanf("%d",&score[i]);
}
for(i=0;i<N;i++){
sum = sum + score[i];
}
avg = (double)sum / N;
printf("avg = %.2f\n",avg);
printf("fail:\n");
for(i=0;i<N;i++){
if(score[i]<60){
printf("%d: %d\n",i+1,score[i]);
}
}
printf("highest: \n");
int MaxScore = 0;
int MaxPos = 0;
for(i=0;i<N;i++){
score[i];
if(score[i]>MaxScore){
MaxScore = score[i];
MaxPos = i+1;
printf("%d: %d\n",MaxPos ,MaxScore);
}
}
return 0;
}再次請求海綿寶寶大神幫忙 謝謝
把 33 列搬出迴圈即可,如下圖所示
謝謝 海綿寶寶大神解決了我的問題 謝謝