Advertisement
chevengur

Вводный курс: основы C++ | Урок 2: Создание и применение вектора 2/3

Aug 28th, 2023
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     vector<int> month_lengths = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  9.     vector<string> month_name = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
  10.     int number_month;
  11.     cin >> number_month;
  12.     if (number_month >= 1 && number_month <= month_lengths.size()) {
  13.         std::cout << "There are " << month_lengths[number_month-1] << " days in " << month_name[number_month-1] << endl;
  14.     }
  15.     else {
  16.         std::cout << "Incorrect month";
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement