There are a few errors in this code:

  1. The 'scanf' statement is missing the '&' symbol before the 'score' variable. It should be 'scanf("%d", &score);'.

  2. The loop should run from 'i=0' to 'i<10' in order to get scores from 10 judges.

  3. The printf statement before the loop is unnecessary and can be removed.

Here's the corrected code:

#include <stdio.h>
void main( )
{
int score, i, max = 0, min = 100;
float sum = 0;

for(i=0; 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);          

}

C语言代码错误分析及修正:评委评分计算程序

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

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