#include
void main()
{
char c;
for(;;)
{
c=cin.get();
if(c=='m')
cout<<"Good morning\n";
else if(c=='a')
cout<<"Good afternoon\n";
else if(c=='n')
cout<<"Good night\n";
else if(c=='e')
break;
else cout<<"Error\n";
}
}
我想输入a时输出Good Afternooon,以此类推,输入的不是"m,a,n,e"中的任意1个时输出Error
但实际上输入"a,n,m"时都会在输出Good XXX后输出Error…
不知原因…求原因&解决方法
|