| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1106 人关注过本帖, 1 人收藏
标题:我不知道为什么进不了循环
取消只看楼主 加入收藏
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
结帖率:60%
收藏(1)
已结贴  问题点数:30 回复次数:6 
我不知道为什么进不了循环
这个是题目
Your roommate is not very familiar with Chinese Railway, and always get confused what the train number means. Now it's time to help him out.
In China, train number contains a lot of information. In this problem, you are supposed to answer the type of train. Train numbers are mainly numbered in following rules:
1. In this problem, you are given a train number containing 2~5 character, where the first character can be either digits or upper-case letter, and other characters are all digits.
2. If the first character is a letter, the train type is determined by the first letter:
'K': Rapid
'T' or 'Q': Express
'Z': SuperExpress
'D': EMUExpress
'G' or 'C': HighSpeed
3. If the first character is a digit, the train type is determined by the integer S the train number forms. To simplify the problem, you may assume:
1000 <= S < 6000: Semi-fast
S >= 6000: Local
And you may assume that no test case will contain any string that was not mentioned in the description.
Input
First line: number of test cases T;
2 ~ T+1 line: Train number.
Output
For each case, output the train type described before.
ATTENTION: Don't modify the names, or you will get WA, copying and pasting them are strongly recommended.
Sample Input
3
4419
Z61
G101

Sample Output
Semi-fast
SuperExpress
HighSpeed


这是我的程序
int main(int argc, char* argv[])
{   
    int m,i;
    char c;
    scanf("%d",&m);

    for(i=1;i<=m;i++)//我的问题是为什么进不去循环啊
    {
        getchar(c);
        switch(c)
        {
           case 'K':printf("Rapid");break;
           case 'T':case 'Q':printf("Express");break;
           case 'Z':printf("SuperExpress");break;
           case 'D':printf("EMUExpress");break;
           case 'G':case 'C':printf("HighSpeed");break;

           case '1':case '2':case '3':case '4':case '5':case '6':printf("Semi-fast"); break;
           default:printf("Local");
        }
        
    }
    return 0;
}
搜索更多相关主题的帖子: familiar following character train Chinese 
2012-11-07 14:05
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
收藏
得分:0 
回复 楼主 王思源
真是太感谢啦!真的可以了
不过我还是没懂为什么一定要这样啊,我怎么觉得以前没有听说过也没有用过啊??
2012-11-07 22:04
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
收藏
得分:0 
回复 2楼 hejian11
真是太感谢啦!真的可以了
不过我还是没懂为什么一定要这样啊,我怎么觉得以前没有听说过也没有用过啊??
2012-11-07 22:05
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
收藏
得分:0 
回复 5楼 一个孩子
为什么要接收回车呢?scanf中不是回车可以表示输入结束吗?
2012-11-08 14:46
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
收藏
得分:0 
回复 9楼 hfhf2006
不行啊 这个题目是要先输入一个数据表示这么多次询问,但是这里的数输不进去,就是没有循环啊,第一个数字没有被当成要做多少次,而是当成了火车的号码。
2012-11-08 14:48
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
收藏
得分:0 
嗯大致懂了 谢谢 不过我不怎么懂 getchar(c)和c=getchar()有什么区别呢?
2012-11-08 23:50
王思源
Rank: 1
等 级:新手上路
帖 子:33
专家分:1
注 册:2012-9-16
收藏
得分:0 
回复 17楼 hejian11
不会不给分的  
2012-11-09 23:10
快速回复:我不知道为什么进不了循环
数据加载中...
 
   



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

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