Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- using namespace std;
- int main()
- {
- int month_number{};
- SetConsoleOutputCP(1251);
- while (true) {
- cout << "Введіть номер місяця: ";
- cin >> month_number;
- if (cin.fail() || cin.peek() != '\n' || month_number < 1 || month_number > 12) {
- cin.clear();
- cin.ignore(32767, '\n');
- cout << "Номер місяця було введено неправильно. Спробуйте ще раз!" << endl;
- continue;
- }
- else {
- break;
- }
- }
- if (month_number == 12 || month_number == 1 || month_number == 2) {
- cout << "Зима" << endl;
- }
- else if (month_number >= 3 && month_number <= 5) {
- cout << "Весна" << endl;
- }
- else if (month_number >= 6 && month_number <= 8) {
- cout << "Літо" << endl;
- }
- else if (month_number >= 9 && month_number <= 11) {
- cout << "Осінь" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement