#include<stdio.h>
#include<stdlib.h>
int main()
{
int x=0,y=0,z=0;
char ch;
printf("Please input a string end by #:\n");
while((ch=getchar())!='#')
{
if(ch==' ')
{
y++;
}else if(ch=='\n')
{
z++;
}
else
{
x++;
}
}
getchar();
printf("space: %d,newline: %d,others: %d\n",y,z,x);
}
统计用户输入从键盘读取用户输入直到遇到#字符,编写程序统计读取的空格数目、读取的换行符数目以及读取的所有其他字符数目。(要求用getchar()输入字符)输入格式: getchar()输出格式:输
最新推荐文章于 2024-04-28 19:01:26 发布