码迷,mamicode.com
首页 > 其他好文 > 详细

2015年4月28日

时间:2015-04-29 00:40:14      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

#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;
}

 

 

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

2015年4月28日

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!