2015年4月28日

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(int argc, const char * argv[]) {
// 统计键盘输入的字符中字母,数字,其他字符的个数,ctl+z结束
//打印出统计图

int alp,num,oth;
char ch;

ch = getchar();
while ((ch) != EOF){
alp = 0;
num = 0;
oth = 0;

while(ch != ' '){

if (isalpha(ch))
alp++;
else if (isalnum(ch))
num++;
else
oth++;
ch = getchar();
}
printf("alp:%d,num:%d,oth:%d ",alp,num,oth);
ch = getchar();
}

system("pause");
return 0;
}

实现循环统计,折腾了几个小时。

原文地址:https://www.cnblogs.com/luolizhi/p/4464421.html