C语言,输入一段字符串,分别统计其中大写,小写,数字,字符的个数,并输出

如题所述

#include "stdio.h"
#include "conio.h"
 
int main()
{
    char s[100],*p=s;
    int num,upper,lower,other;
    num=upper=lower=other=0;
    printf("Please enter a string:");
    gets(s);
    for(;*p!='\0';p++)
    {
        if(*p>='0' && *p<='9') num++;
        else if(*p>='a'&&*p<='z') lower++;
        else if(*p>='A'&&*p<='Z') upper++;
        else other++;
    }
    printf("num=%d,upper=%d,lower=%d,other=%d",num,upper,lower,other);
    getch();
    return 0;
}

祝你成功!

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-06-09
有专门的字符串处理方法
第2个回答  2021-04-05

C语言字符串的学习,输入指定字符串,并且计算字符串的位数

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网