热门

最新

红包

立Flag

投票

同城

我的

发布
m0_73848965
小舍快醒醒
4 年前
truem0_73848965

<输入一个字符串,统计其中的字母、空格、数字、其他字符>
#include <stdio.h>
void main()
{
int i=0,a=0,b=0,c=0,d=0;
char stt[100];
printf("请输入一个字符串:\n");
gets(stt);
while(stt[i]!='\0')
{
if(stt[i]>='a'&&stt[i]<='z'||stt[i]>='A'&&stt[i]<='Z')
{
a++;
}
else if(stt[i]>='0'&&stt[i]<='9')
{
b++;
}
else if(stt[i]==' ')
{
c++;
}
else
{
d++;
}
i++;
}
printf("char=%d space=%d number=%d others=%d\n",a,c,b,d);
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
不知道写什么文章了各位推荐一下,帮我想想灵感
立即登录