关于C++中while的问题,不知道哪错了,总是一直输出答案,根本停不下来。。。求大神指点啊

#include<iostream>usingnamespacestd;intmain(){inta,b,c;cin>>a>>b;if(a%4==0){while(b==... #include<iostream>using namespace std;int main(){ int a, b, c; cin >> a >> b; if (a % 4 == 0) { while (b==2) cout << "February" << " " << a << " " << "has 29 days" << endl; return 0; while (b == 1) cout << "January" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 3) cout << "March" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 4) cout << "Apri" << " " << a << " " << "has 30 days" << endl; return 0; while (b == 5) cout << "May" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 6) cout << "June" << " " << a << " " << "has 30 days" << endl; return 0; while (b == 7) cout << "July" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 8) cout << "August " << " " << a << " " << "has 31 days" << endl; return 0; while (b == 9) cout << "September" << " " << a << " " << "has 30 days" << endl; return 0; while (b == 10) cout << "October" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 11) cout << "November " << " " << a << " " << "has 30 days" << endl; return 0; while (b == 12) cout << "December" << " " << a << " " << "has 31 days" << endl; return 0; } else if (a % 4 != 0) { while (b == 2) cout << "February" << " " << a << " " << "has 28 days" << endl; return 0; while (b == 1) cout << "January" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 3) cout << "March" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 4) cout << "Apri" << " " << a << " " << "has 30 days" << endl; return 0; return 0; while (b == 5) cout << "May" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 6) cout << "June" << " " << a << " " << "has 30 days" << endl; return 0; while (b == 7) cout << "July" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 8) cout << "August " << " " << a << " " << "has 31 days" << endl; return 0; while (b == 9) cout << "September" << " " << a << " " << "has 30 days" << endl; return 0; while (b == 10) cout << "October" << " " << a << " " << "has 31 days" << endl; return 0; while (b == 11) cout << "November " << " " << a << " " << "has 30 days" << endl; return 0; while (b == 12) cout << "December" << " " << a << " " << "has 31 days" << endl; return 0; } return 0;} 展开
 我来答
re...4@163.com
推荐于2016-07-05 · 超过21用户采纳过TA的回答
知道答主
回答量:39
采纳率:0%
帮助的人:35万
展开全部
你把所有的while改为if就可以了,或在每个while语句块中假如break;
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式