题解 | #统计字符#

统计字符

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

#include<stdio.h>
#include<string.h>
int main(){
    int count_eng=0,count_kong=0,count_num=0,count_other=0;
    char str[1001]={'\0'};
    while(scanf("%[^\n]",str)>0){
        for(int i=0;i<strlen(str);i++){
           if((str[i]>='A'&&str[i]<='Z')||(str[i]>='a'&&str[i]<='z'))
               count_eng=count_eng+1;
            else if(str[i]==' ')
                count_kong=count_kong+1;
            else if(str[i]>='0'&&str[i]<='9')
                count_num=count_num+1;
            else
               count_other=count_other+1; 
        }
    }
    printf("%d\n%d\n%d\n%d",count_eng,count_kong,count_num,count_other);
}
全部评论

相关推荐

Yki_:你要算时间成本呀,研究生两三年,博士三四年,加起来就五六年了,如果你本科去腾讯干五年,多领五年的年薪,加上公司内涨薪,可能到时候十五年总薪资也跟博士差不多
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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