C语言:输入一组数,统计其中奇数和偶数的个数,知道遇到回车为止.怎样写啊,1楼的不行,2楼的有4个错误:--------------------Configuration:6(3) - Win32 Debug--------------------Compiling...6(3).cC:\Documents and Setti
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/14 00:36:53
![C语言:输入一组数,统计其中奇数和偶数的个数,知道遇到回车为止.怎样写啊,1楼的不行,2楼的有4个错误:--------------------Configuration:6(3) - Win32 Debug--------------------Compiling...6(3).cC:\Documents and Setti](/uploads/image/z/574361-17-1.jpg?t=C%E8%AF%AD%E8%A8%80%EF%BC%9A%E8%BE%93%E5%85%A5%E4%B8%80%E7%BB%84%E6%95%B0%2C%E7%BB%9F%E8%AE%A1%E5%85%B6%E4%B8%AD%E5%A5%87%E6%95%B0%E5%92%8C%E5%81%B6%E6%95%B0%E7%9A%84%E4%B8%AA%E6%95%B0%2C%E7%9F%A5%E9%81%93%E9%81%87%E5%88%B0%E5%9B%9E%E8%BD%A6%E4%B8%BA%E6%AD%A2.%E6%80%8E%E6%A0%B7%E5%86%99%E5%95%8A%2C1%E6%A5%BC%E7%9A%84%E4%B8%8D%E8%A1%8C%2C2%E6%A5%BC%E7%9A%84%E6%9C%894%E4%B8%AA%E9%94%99%E8%AF%AF%EF%BC%9A--------------------Configuration%3A6%283%29+-+Win32+Debug--------------------Compiling...6%283%29.cC%3A%5CDocuments+and+Setti)
C语言:输入一组数,统计其中奇数和偶数的个数,知道遇到回车为止.怎样写啊,1楼的不行,2楼的有4个错误:--------------------Configuration:6(3) - Win32 Debug--------------------Compiling...6(3).cC:\Documents and Setti
C语言:输入一组数,统计其中奇数和偶数的个数,知道遇到回车为止.怎样写啊,
1楼的不行,2楼的有4个错误:--------------------Configuration:6(3) - Win32 Debug--------------------
Compiling...
6(3).c
C:\Documents and Settings\Administrator\桌面\6(3).c(353) :error C2143:syntax error :missing ';' before 'type'
C:\Documents and Settings\Administrator\桌面\6(3).c(354) :error C2065:'i' :undeclared identifier
C:\Documents and Settings\Administrator\桌面\6(3).c(358) :error C2065:'a' :undeclared identifier
C:\Documents and Settings\Administrator\桌面\6(3).c(362) :error C2065:'b' :undeclared identifier
Error executing cl.exe.
6(3).obj - 4 error(s),0 warning(s)
C语言:输入一组数,统计其中奇数和偶数的个数,知道遇到回车为止.怎样写啊,1楼的不行,2楼的有4个错误:--------------------Configuration:6(3) - Win32 Debug--------------------Compiling...6(3).cC:\Documents and Setti
/***以下我觉得自己算写得比较好的了.你可以输入任意多个字符,而且有非数字字符等各种错误输入也不会影响统计.希望对你有所帮助.**/
/***
** 输入一组数,统计奇数和偶数的个数.
**/
#include
int main(void){
char ch;
int num;
int even_num = 0;//纪录偶数个数
int old_num = 0;//奇数个数.
int other = 0;//其它字符个数
printf("请输入一组数字(回车则表示结束!):\n\t");
do{
do{
ch = getchar();
}while(ch==' ');
if(ch=='\n')break;
else if(ch>='0'&&ch0){
printf("\t同时以上输入了:%2d个非数字字符\n",other);
}
return 0;
}///main:
/***以下为输入输出结果示列:
请输入一组数字(回车则表示结束!):
1 2 3 # 4 5 6
以上输入的数中,奇数有:3 个,偶数有:3 个
同时以上输入了:1个非数字字符
----------------------------------------
请输入一组数字(回车则表示结束!):
1 2 3 4 5 6 7 8
以上输入的数中,奇数有:4 个,偶数有:4 个
**/