字符个数
输入一行字符,分别统计出其中英文字母、数字、空格和其他字符的个数。
输入
一行字符
输出
统计值
样例输入
aklsjflj123 sadf918u324 asdf91u32oasdf/.';123
样例输出
23 16 2 4
#include <stdio.h> int main() { int letter=0,space=0,number=0,others=0; char nextchar; for(;nextchar!='\n';) { scanf("%c",&nextchar); if(('a'<=nextchar&&nextchar<='z')||('A'<=nextchar&&nextchar<='Z')) letter++; else if(nextchar==' ') space++; else if('0'<=nextchar&&nextchar<='9') number++; else others++; } printf("%d %d %d %d\n",letter,number,space,--others); return 0; }