学生兼职做什么好:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
来源:百度文库 编辑:查人人中国名人网 时间:2024/10/05 09:26:40
我的代码错在哪啦。。。。
#include <stdio.h>
main()
{
char c;
int letter=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')
letter++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("all in all:letter=%d space=%d digit=%d others=%d\n",letter,space,digit,others);
getch();
}
thank可是我想结束输入应该怎么结束呢?
回车不好用啊
按ctrl+z只出现^Z符号啊
#include <stdio.h>
main()
{
char c;
int letter=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')
letter++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("all in all:letter=%d space=%d digit=%d others=%d\n",letter,space,digit,others);
getch();
}
thank可是我想结束输入应该怎么结束呢?
回车不好用啊
按ctrl+z只出现^Z符号啊
if(c>='a'%%c<='z'||c>='A'&&c<='Z'
%%应该是&&吧?
((c=getchar())!="\n" 这个一直成立
该成!='\0'试试,不记得换行是啥了
按Ctrl+Z强行结束输入
题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
编程:输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数。
题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
输入一行数,分别统计出其中英文字母、空格、数字和其他字符的个数
C语言 输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。
C问题,用FOR语句做:输入一行字符,分别统计其中英文字母,空格,数字和其他字符的个数.
C语言编程:输入一行字符,统计出其中英文字母、空格、数字和其他字符的个数
输入一行字符,要求统计出英文字母、数字、空格和其它字符的个数
输入一行数字字符,用整型数组统计其中每个数字字符的个数,下标为零的元素存放'0'的个数……