2019.3.1苏小红C语言

1.打分统计并按格式输出

for (i = 0; i < M; i++)
    {
        switch (feedback[i])
        {
            case 1: count[1]++; break;
            case 2: count[2]++; break;
            case 3: count[3]++; break;
            case 4: count[4]++; break;
            case 5: count[5]++; break;
            case 6: count[6]++; break;
            case 7: count[7]++; break;
            case 8: count[8]++; break;
            case 9: count[9]++; break;
            case 10: count[10]++; break;
            default:printf("input error! \n");
        }
    }

还可以用一行解决:

for (i = 0; i < M; i++)
{
    count[feedback[i]]++;
}

紧接着可以找出这些数的众数(Mode)

int max = 0;
for (grade = 1; grade <= N-1; grade++)
{
    if (count[grade] > max)
    {
        max = count[grade];
        modeValue = grade;    //下标
    }
}
return modeValue;

你可能感兴趣的:(2019.3.1苏小红C语言)