关于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;}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询