题解 | #统计字符#

统计字符

http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5

插个楼:

#include<stdio.h>
#include<ctype.h>
int main(){
    int alpha=0,space=0,digit=0,other=0;
    char str[1002];
    while(fgets(str,1002,stdin)){
        alpha=0,space=0,digit=0,other=0;
        for(int i=0;str[i]!='\n';i++){
            if(isalpha(str[i]))
                alpha++;
            else if(str[i]==' ')
                space++;
            else if(isdigit(str[i]))
                digit++;
            else
                other++;
        }
    printf("%d\n%d\n%d\n%d\n",alpha,space,digit,other);
    }
}
全部评论

相关推荐

榕城小榕树:1200单休,我去干点啥别的不好
点赞 评论 收藏
分享
点赞 评论 收藏
分享
07-09 15:55
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务