标题:检查不出问题,请大家不吝赐教。
取消只看楼主
jiangchuanze
Rank: 2
等 级:论坛游民
帖 子:8
专家分:13
注 册:2012-1-19
 问题点数:0 回复次数:1 
检查不出问题,请大家不吝赐教。
/*output the student score in A,B,C,D,E class*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
        int score;
        char ch;
   test:{
        printf("please input the score: ");
        scanf("%d",&score);

        if(score>=90)
                ch='A';
        else if(score>=80&&score<=89)
                ch='B';
        else if(score>=70&&score<=79)
                ch='C';
        else if(score>=60&&score<=69)
                ch='D';
        else
                ch='E';

        printf("this student score is : %c class\n",ch);
     test2:  {
        printf("continue the test , Y/N ? : ");
        char judge='Y';
        scanf("%c",&judge);
        if(judge=='Y'||judge=='y')
                goto test;
        else if(judge=='N'||judge=='n')
                exit(0);
        else
                printf("Error :wrong input!!!!!!!! \n");
                goto test2;
       }
}

return 0;
}

输入23后,运行结果
please input the score: 23
this student score is : E class
continue the test , Y/N ? : Error :wrong input!!!!!!!!
continue the test , Y/N ? :
 
请大家分析一下为什么会出现continue the test , Y/N ? : Error :wrong input!!!!!!!!
搜索更多相关主题的帖子: 检查 class include please 
2012-02-11 19:44
jiangchuanze
Rank: 2
等 级:论坛游民
帖 子:8
专家分:13
注 册:2012-1-19
得分:0 
回复 2楼 chenliangjs
谢谢,运行正确,但是再请教一下,为什么在按下回车的时候还是要再scanf一次?这样的情况在什么条件下才会发生?
2012-02-16 10:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360756-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.619321 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved