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 != '\n'){

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

system("pause");
return 0;
}

 

 

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

posted on 2015-04-28 23:30  IT小不点  阅读(114)  评论(0编辑  收藏  举报