| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 544 人关注过本帖
标题:请各位看看问题出在哪里了
只看楼主 加入收藏
syg823
Rank: 1
等 级:新手上路
帖 子:21
专家分:9
注 册:2010-9-19
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:10 
请各位看看问题出在哪里了
#include<stdio.h>
main()
{
    int score=0;
    printf("please input your score:\n");
        scanf("%d",&score);
        if((score>100)||(score<0))
            printf("please input your score again!\n");
        switch(score/10)
        {
           case 10:
               printf("the score is A.\n")
               break;
           case 9:
               printf("the score is A.\n")
               break;
           case 8:
               printf("the score is B.\n")
               break;
           case 7:
               printf("the score is C.\n")
               break;
           case 6:
               printf("the score is D.\n")
               break;
           default:
               printf("the score is E.\n")
        }
}
搜索更多相关主题的帖子: include please 
2010-11-11 09:11
vvvevvv
Rank: 2
来 自:黑龙江
等 级:论坛游民
帖 子:129
专家分:92
注 册:2010-9-9
收藏
得分:10 
程序代码:
#include<stdio.h>
main()
{
    int score;
    printf("please input your score:\n");
        scanf("%d",&score);
        if((score>100)||(score<0))
            printf("please input your score again!\n");
        switch(score/10)
        {
           case 10:
               printf("the score is A.\n");//每个printf后面要加“ ;”
               break;//你的之前都是中文的 呵呵 马虎了!
           case 9:
               printf("the score is A.\n");
               break;
           case 8:
               printf("the score is B.\n");
               break;
           case 7:
               printf("the score is C.\n");
               break;
           case 6:
               printf("the score is D.\n");
               break;
           default:
               printf("the score is E.\n");
        }
} 

学习~
2010-11-11 09:28
syg823
Rank: 1
等 级:新手上路
帖 子:21
专家分:9
注 册:2010-9-19
收藏
得分:0 
回复 2楼 vvvevvv
这个c语言是课本上的,但是输入后提示错误,和书上一样的,请问哪里是中文的啊,有点不太明白
2010-11-11 09:31
syg823
Rank: 1
等 级:新手上路
帖 子:21
专家分:9
注 册:2010-9-19
收藏
得分:0 

这个我是用另一种方法做的,提示一个错误,就是在“int:x=100,&&,x<100;”这个地方错误


#include<stdio.h>
main()
{
    int: x=100,&&,x<100;
         else if(x<=100,&&,x>=90)
              printf("a\n")
              else if(x<90,&&,x>=80)
                   printf("b\n")
                   else if(x<80,&&,x>=70)
                        printf("c\n")
                        else if(x<70,&&,x>=60)
                             printf("d\n")
                                else if(x<0)
                                  printf("Error\n")
}
2010-11-11 09:34
木头lbj
Rank: 7Rank: 7Rank: 7
来 自:黄山
等 级:黑侠
威 望:1
帖 子:269
专家分:527
注 册:2010-11-6
收藏
得分:5 
break前有;
加上头文件#include <math.h>
最后的default语句最后也加上break比较好
下面是我改了之后的代码在VC6.0中运行成功。
#include<stdio.h>
#include<math.h>
main()
{
    int score;
    printf("please input your score:\n");
        scanf("%d",&score);
        if((score>100)||(score<0))
            printf("please input your score again!\n");
        switch(score/10)
        {
           case 10:
               printf("the score is A.\n");
               break;
           case 9:
               printf("the score is A.\n");
               break;
           case 8:
               printf("the score is B.\n");
               break;
           case 7:
               printf("the score is C.\n");
               break;
           case 6:
               printf("the score is D.\n");
               break;
           default:
               printf("the score is E.\n");
               break;
        }
}
如果你是在WIN-tc中编译可能最后还要加一句getch();

。。。!!!)))000
2010-11-11 09:43
vvvevvv
Rank: 2
来 自:黑龙江
等 级:论坛游民
帖 子:129
专家分:92
注 册:2010-9-9
收藏
得分:5 
回复 3楼 syg823
你照着输  丢掉了很多东西!!比如 你看 printf 后面  一条语句结束 要加“;”(分号,一定要在英文输入法的状态下)!!
你的 printf 后面丢了分号。同时break语句后面你的分号 是在中文输入法的状态下输入的!!

学习~
2010-11-11 09:46
syg823
Rank: 1
等 级:新手上路
帖 子:21
专家分:9
注 册:2010-9-19
收藏
得分:0 
回复 6楼 vvvevvv
哦,明白了,我试试啊,谢谢啊!
2010-11-11 09:49
vvvevvv
Rank: 2
来 自:黑龙江
等 级:论坛游民
帖 子:129
专家分:92
注 册:2010-9-9
收藏
得分:0 
回复 4楼 syg823
至于你说的if-else结构的问题
它的格式应该是
if(表达式1)
语句1
else if(表达式2)
语句2
.
.
.
else if(表达式n)
语句n
else(表达式n+1)
语句n+1

你的结构有问题
还有你的变量声明 也有问题
还是先看看书吧  一遍不行 就多遍!!加油~~

学习~
2010-11-11 09:59
vvvevvv
Rank: 2
来 自:黑龙江
等 级:论坛游民
帖 子:129
专家分:92
注 册:2010-9-9
收藏
得分:0 
程序代码:
#include<stdio.h>
void main()
{
    int x;
    scanf("%d",&x);
          if(x<=100 && x>=90)
              printf("a\n");
              else if(x<90 && x>=80)
                   printf("b\n");
                   else if(x<80 && x>=70)
                        printf("c\n");
                        else if(x<70 && x>=60)
                             printf("d\n");
                            else if(x<60&&x>0)
                                printf("e\n");
                                  else
                                  printf("Error\n");
} 

学习~
2010-11-11 10:03
闯者善行
Rank: 2
等 级:论坛游民
帖 子:8
专家分:20
注 册:2010-11-8
收藏
得分:0 
正确的              #include<stdio.h>
main()
{
    int score=0;
    printf("please input your score:\n");
        scanf("%d",&score);
        if((score>100)||(score<0))
            printf("please input your score again!\n");
        switch(score/10)
        {
           case 10:
               printf("the score is A.\n") ;   break;
            
           case 9:
               printf("the score is A.\n") ;  break;
              
           case 8:
               printf("the score is B.\n") ;  break;
               
           case 7:
               printf("the score is C.\n") ;  break;
              
           case 6:
               printf("the score is D.\n") ;  break;
            
           default:
               printf("the score is E.\n");
        }
}
2010-11-11 12:15
快速回复:请各位看看问题出在哪里了
数据加载中...
 
   



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

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