There are several errors in this code:

  1. The return type of the main function should be 'int', not 'void'.
  2. The 'scanf' function requires the address of the variable being read into, so the argument for 'scanf' should be '&score', not 'score'.
  3. The loop should run for 10 iterations, not 9.
  4. The formula for calculating the average score should divide by 8, not 10, since the highest and lowest scores are being removed.

Corrected code:

#include <stdio.h>

int main( ) { int score,i,max=0,min=100; float sum=0;

printf("Input scores:

");

for(i=1;i<=10;i++)
{
    scanf("%d",&score);  /*输入评委的评分*/
    sum+=score;        /*计算总分*/
    if(score>max) max=score;    /*通过比较筛选出其中的最高分*/
    if(score<min) min=score;    /*通过比较筛选出其中的最低分*/
}
printf("Canceled max score:%d\nCanceled min score:%d\n",max,min);
printf("Average score:%.3f\n",(sum-max-min)/8.0);

return 0;

}

C语言代码错误分析及修正:评委评分系统

原文地址: https://www.cveoy.top/t/topic/mOc5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录