
朋友啊,你是不是念困早仔雀忘记输入&这个字符了啊?scanf是要取地址的,就是将尺毕你从键盘上输入的数字存放在a上,所以你应该是:scanf("%d",&a)
至于别的应该没错了。。。。
1.程序分析:利用while语句,条件为唤历链输入的字符不为烂羡'\n'.2.程序源代码:
#include "stdio.h"
main()
{char c
int letters=0,space=0,digit=0,others=0
printf("please input some characters\n"和孙)
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++
else if(c==' ')
space++
else if(c>='0'&&c<='9')
digit++
else
others++
}
printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,
space,digit,others)
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)