早教吧作业答案频道 -->其他-->
1.输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。不一样的答案
题目详情
1. 输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。 不一样的答案
▼优质解答
答案和解析
#include
void 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);
}
void 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);
}
看了 1.输入一行字符,分别统计出...的网友还看了以下:
找一找(1)找出相同的除数.61÷□=□…569÷□=□…577÷□=□…5相同的除数是.(2)找 2020-04-07 …
在横线里填上合适的数.(1)1,3,7,15,31,,.(2)有一串式子2+4,8+5,14+6, 2020-05-14 …
用0、3、4、9写数.(1)写一个不读出0的小数.(2)写出一个只读一个0的小数.(3)写出一个最 2020-06-11 …
(2012•绍兴三模)在函数中,我们把关于x的一次函数y=ax+b与y=bx+a称为一对交换函数, 2020-07-07 …
任何一个整数N,可以用一个的多项式来表示:N=.anan-1a1a0=an×10n+an-1×10 2020-07-09 …
明明写了一个八位数.从右起单数位上的数字是最小的一位数.双数位上的数字是最大的一位数.(1)写出这个 2020-11-17 …
用2,1,0,0,0,0,8,9这8个数字,按要求写出八位数.(1)最小的数.(2)最接近1亿的数. 2020-11-18 …
用2,1,0,0,0,0,8,9这8个数字,按要求写出八位数.(1)最小的数.(2)最接近1亿的数. 2020-11-18 …
一个数(0除外)乘大于1的数,积比原来的数.一个数(0除外)乘小于1的数,积比原来的数.一个数(0除 2020-11-20 …
明明写了一个八位数.从右起单数位上的数字是最小的一位数.双数位上的数字是最大的一位数.(1)写出这个 2020-11-20 …