35657

Untitled

Feb 17th, 2024
1,387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.     setlocale(LC_ALL, "Russian");
  9.  
  10.     int month_number, day_number, days_count = 31;
  11.  
  12.     cout << "Введите номер месяца: ";
  13.     cin >> month_number;
  14.  
  15.  
  16.     cout << "Введите номер дня: ";
  17.     cin >> day_number;
  18.  
  19.     int sunday = 8 - day_number;
  20.     int saturday = sunday - 1;
  21.     int weekend = 0;
  22.  
  23.     if (month_number == 4 || month_number == 6 || month_number == 9 || month_number == 11) {
  24.         days_count = 30;
  25.     }
  26.     if (month_number == 2) {
  27.         days_count = 28;
  28.     }
  29.  
  30.     cout << "\tMo\tTu\tWe\tTh\tFr\tSa\tSu" << endl;
  31.  
  32.     for (int i = 1; i < day_number; i++) {
  33.         cout << "\t_";
  34.     }
  35.  
  36.     for (int i = 1; i <= days_count; i++) {
  37.         cout << "\t" << i;
  38.         if (i == saturday) {
  39.             weekend++;
  40.         }
  41.         if (i == sunday) {
  42.             cout << endl;
  43.             weekend++;
  44.             sunday += 7;
  45.             saturday += 7;
  46.         }
  47.     }
  48.     cout << endl << endl;;
  49.     cout << "\tВ месяце " << weekend << " выходных" << endl;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment