金属铸造性能的好坏:我的程序退步出来

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 01:11:44
我的c语言程序退不出来,各位高手来帮忙看一下
下面是我的c语言程序:#include"stdio.h"
main()
{int letter=0,bspace=0,digit=0,other=0;
char ch;
int in;
ch=getchar();
in=getchar();
while(ch!='\n'||in!='\n')

{if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
letter++;
else if(in>='0'&&in<='9')
digit++;
else if((ch==' ')
bspace++;
else other++;
}
printf("letter=%d,bspace=%d,digit=%d,other=%d\n",letter,bspace,digit,other);
}
第一次运行时没有报错,但是当我在运行界面输入字母,数字在敲回车后却不能回到程序界面,且不能再输入任何东西。死在那里了。
请各位高手来帮帮小弟,先在此谢过了!

是while(ch!='\r'||in!='\r')

#include"stdio.h"
main()
{int letter=0,bspace=0,digit=0,other=0;
char ch;
while(ch=getchar()!='\n')
{
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
letter++;
else if(ch>='0'&&ch<='9')
digit++;
else if(ch==' ')
bspace++;
else other++;
}
printf("letter=%d,bspace=%d,digit=%d,other=%d\n",letter,bspace,digit,other);
getch();
}

是while(ch!='\r'||in!='\r')
回答者:yhing - 秀才 二级 5-26 16:03

#include"stdio.h"
main()
{int letter=0,bspace=0,digit=0,other=0;
char ch;
while(ch=getchar()!='\n')
{
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
letter++;
else if(ch>='0'&&ch<='9')
digit++;
else if(ch==' ')
bspace++;
else other++;
}
printf("letter=%d,bspace=%d,digit=%d,other=%d\n",letter,bspace,digit,other);
getch();
}