标题:[开动脑筋]大家来尽情发挥,简单程序
只看楼主
凉拌粉丝
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-6-30
得分:0 
#include <iostream>
using namespace std;
void main()
{
char answer;
while(1)
{
cout<<"现在还下雨吗?(Y/N)"<<endl;
cin>>answer;
if(answer=='Y'||answer=='y')
{ cout<<"现在正在下雨。"<<endl;
break;
}
else if(answer=='N'||answer=='n')
{
cout<<"现在没有下雨。"<<endl;
break;
}

}
}
楼主这样就可以了,不需要用goto 语句的。我已经调试通过了。

2007-10-15 19:49
dart
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-9-2
得分:0 
#include<iostream>
using namespace std;
int main()
{
char str;
step:cout<<"现在下雨吗?"<<endl;
cin>>str;
if(str!='Y'||str!='y'||str!='n'||str!='N')
goto step;
else if(str=='Y'||str=='y')
cout<<"现在在下雨"<<endl;
else
cout<<"现在没有下雨"<<endl;

goto step;
return 0;
}
2007-10-16 13:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-167175-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.129221 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved