C语言编程,请教高手....

来源:百度知道 编辑:UC知道 时间:2024/09/21 18:17:43
两班个40人,输入百分制成绩,将百分制成绩转换为5分制
(>90为A,89~90为B......60分以下是E);然后输出每个班级的各个分数段的人数(五分之情况下)

#include <stdio.h>
main()
{
int a[2][40]cnt[5]={0};
int i,j;
for(i=0;i<2;i++)
{
printf("input the %dth class's scores:",i+1);
for(j=0;j<40;j++)
scanf("%d",&a[i][j]);
}
printf("the scores are:");
for(i=0;i<2;i++)
for(j=0;j<40;j++)
switch(a[i][j]/10)
{
case 1:
case 2:
case 3:
case 4:
case 5:printf("A ");cnt0++;break; /* cnt0 统计A段人数*/
case 6:printf("B ");cnt1++;break; /* cnt1 统计B段人数*/

case 7:printf("C ");cnt2++;break; /* cnt2 统计C段人数*/

case 8:printf("D ");cnt3++;break; /* cnt3 统计D段人数*/

case 10:
case 9:printf("E ");cnt4++;break; /* cnt4统计E段人数*/

}
}

我试着理解你的意思给你写下:
#include <stdio.h>
main()
{
int a[2][40];
int i,j;
for(i=0;i<2;i++)
{
printf("input