c语言编程题目没有错误但是运行无反应

2024-11-16 10:15:51
推荐回答(4个)
回答1:

#include
#include
int main()
{
    int score,i,n,t;
    while(scanf("%d",&n)!=EOF)//这里要干嘛呢?
    {
        for(i=1; i<=n; i++)
        {
            printf("请输入成绩");
            scanf("%d",&score);
            t=score/10;
            switch(t)
            {
            case 10:
            case 9:
                printf("A\n");
                break;
            case 8:
                printf("B\n");
                break;
            case 7:
                printf("C\n");
                break;
            case 6:
                printf("D\n");
                break;
            default:
                printf("E\n");
                break;
            }
        }
    }
    return 0;

}

你这程序语法都有问题呢。给你修改好了

回答2:

#include
#include
int main()
{
int score,i,n,t;
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++) //第一个错误,不是逗号是分号;
{
scanf("%d",&score);
t=score/10;
switch(t) //第二个错误点,后面的分号不要添加
{ //第三个错误点,要加花括号{} 才能把所有的case包含在内
case 10:
case 9:printf("A\n");break;
case 8:printf("B\n");break;
case 7:printf("C\n");break;
case 6:printf("D\n");break;
default:printf("E\n");break;
}
}
}
system("PAUSE");
return 0;
}

回答3:

switch(t) //这里不要分号
{//这里漏了分号
case 10:
case 9:printf("A\n");break;
case 8:printf("B\n");break;
case 7:printf("C\n");break;
case 6:printf("D\n");break;
default:printf("E\n");break;
}

回答4:

switch()
{
}
没有分号的;