输入格式:
输入在一行中给出若干字符,最后一个回车表示输入结束,不算在内。
输出格式:
在一行内按照:
blank = 空格个数, digit = 数字字符个数, other = 其他字符个数
输出。
在这里给出一组输入。例如:
Reold 12 or 45T
输出样例:
在这里给出相应的输出。例如:
blank = 3, digit = 4, other = 8
c语言代码实现如下:
#include<stdio.h>
int main()
{
int digit, other, blank;
char ch;
digit=0,blank=0,other=0;
//首先定义计数变量并初始化
while((ch=getchar())!='\n')
{ //当输入不等于回车时循环
//根据各种情况用if语句判断来设置变量的值
if(ch>='0'&&ch<='9')
digit++;
else if(ch==' ')
blank++;
else
other++;
} //最后按照题目给出的格式进行打印输出
printf("blank = %d, digit = %d, other = %d\n",blank,digit,other);
return 0;
}