| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 376 人关注过本帖
标题:统计字符,请大家帮我找找错
取消只看楼主 加入收藏
雾雨淼淼
Rank: 2
来 自:甘肃金昌
等 级:论坛游民
帖 子:85
专家分:89
注 册:2010-8-17
结帖率:100%
收藏
已结贴  问题点数:30 回复次数:1 
统计字符,请大家帮我找找错
程序如下:
# include <stdio.h>
void main()
{
    int num,alp_a,alp_A,oth;
    char a;
    num=0;
    alp_a=0;
    alp_A=0;
    oth=0;
    printf("本程序负责统计输入的字符的类型\n");
    printf("类型有大写字母、小写字母、数字、其他字符\n");
    printf("请输入字符,以ESC退出\n");
    while((a=getchar()))
    {
        switch (a)
        {
            case a>='a' && a<='z':
                alp_a ++;
                break;

            case a>='A' && a<='Z':
                alp_A ++;
                break;
            case a>='0' && a<='9':
                num ++;
                break;
            default:
                oth ++;
                break;
        }
        printf("请输入下一个字符:\n");
    }
    printf("统计结果如下:\n");
    printf("小写字母的个数为:%d",alp_a);
    printf("大写字母的个数为:%d",alp_A);
    printf("数字的个数为:%d",num);
    printf("其他的个数为:%d",oth);
}
编译环境:code::blocks
提示错误:
\num_aip\num_alp.c|2|warning: return type of 'main' is not 'int'|
\num_aip\num_alp.c||In function 'main':|
\num_aip\num_alp.c|17|error: case label does not reduce to an integer constant|
\num_aip\num_alp.c|20|error: case label does not reduce to an integer constant|
\num_aip\num_alp.c|23|error: case label does not reduce to an integer constant|
||=== Build finished: 3 errors, 1 warnings ===|

搜索更多相关主题的帖子: 统计 
2011-06-12 23:24
雾雨淼淼
Rank: 2
来 自:甘肃金昌
等 级:论坛游民
帖 子:85
专家分:89
注 册:2010-8-17
收藏
得分:0 
明白了,非常感谢
2011-06-13 23:04
快速回复:统计字符,请大家帮我找找错
数据加载中...
 
   



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

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