注册 登录
编程论坛 新人交流区

[求助][讨论]if,while,getcher,getchar做C语言题

shenjian 发布于 2007-11-07 16:50, 915 次点击

用if,while,getcher,gether等一系列函数来做一道题:
任意输进东西,比如,A,B,C,D,a,b,x,e,6,54,3,¥等但是在结尾时要用#结尾;
要求输出字母的个数(小写的也算);的C语言题目怎么编啊?我想了很久就是不会,请前辈帮忙啊。速度哦!!!

1 回复
#2
viwa2007-11-07 17:18
#include <stdio.h>
main()
{
char c;
int letters=0;
printf("please input some characters:\n");
while((c=getchar())!='#')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
}
printf("char=%d \n",letters);
}
1