题解 | #判断季节#
判断季节
https://www.nowcoder.com/practice/741a9b79fabe474cb153a49b4bff5828
#include <iostream>
using namespace std;
int main() {
int month;
cin >> month;
// 录入一个月份 month,判断属于哪个季节(3 - 5 月为春季、6 - 8 月为夏季、9 - 11 月为秋季、12,1,2 月为冬季)
if(month == 3 || month == 4 || month == 5) //注意是==,不是=
cout << "春季";
if(month == 6 || month == 7 || month == 8)
cout << "夏季";
if(month == 9 || month == 10 || month == 11)
cout << "秋季";
if(month == 12 || month == 1 || month == 2)
cout << "冬季";
if(month < 1 || month > 12)
cout << "不合法";
return 0;
}
#零基础学习C++#C++每日一练 文章被收录于专栏
C++刷题