题解 | #字符串反转#

统计字符

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

C语言基础解法

include<stdio.h>

include<string.h>

int main()
{
char str[1000];
while(gets(str)){
int leter=0;
int num=0;
int space=0;
int other=0;
int len;
int i;
len=strlen(str);
for(i=0;i<len;i++){
if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))
leter++;
else if((str[i]>='0'&&str[i]<='9'))
num++;
else if(str[i]==32)
space++;
else
other++;
}
printf("%d\n",leter);
printf("%d\n",space);
printf("%d\n",num);
printf("%d\n",other);
}
}

全部评论

相关推荐

哈哈哈,你是老六:我去,这面试还要靠抢啊
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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