Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.  
  12.     int day = 0;
  13.     int month = 0;
  14.     int q = 0;
  15.     int i = 0;
  16.     int NextMonth = 0;
  17.     string command;
  18.     string s;
  19.  
  20.     vector<int> days = { 31,28,31,30,31,30,31,31,30,31,30,31 };
  21.     vector<vector<string>> alpha(days[month]);
  22.  
  23.  
  24.     cin >> q;
  25.  
  26.     for (auto iteration = 0; iteration <= q; iteration++) {
  27.  
  28.         cin >> command;
  29.  
  30.  
  31.         if (command == "ADD") {
  32.             cin >> i >> s;
  33.             alpha[i-1].push_back(s);
  34.         }
  35.         else if (command == "NEXT") {
  36.  
  37.             NextMonth = month + 1;
  38.  
  39.             if (NextMonth > 11)
  40.                 NextMonth = 0;
  41.             if (days[NextMonth] > days[month])
  42.                 alpha.resize(days[NextMonth]);
  43.  
  44.             else {
  45.  
  46.                 int counter = 0;
  47.  
  48.  
  49.                 for (counter = days[month] - 1; counter >= (days[NextMonth] - 1); counter--) {
  50.  
  51.                     alpha[days[NextMonth] - 1].insert(end(alpha[days[NextMonth] - 1]), begin(alpha[counter]), end(alpha[counter]));
  52.                 }
  53.  
  54.                 alpha.resize(days[NextMonth]);
  55.             }
  56.  
  57.             month += 1;
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.         }
  65.  
  66.         else if (command == "DUMP") {
  67.             cin >> i;
  68.  
  69.             for (auto x : alpha[i-1]) {
  70.  
  71.                 cout << x << endl;
  72.             }
  73.  
  74.  
  75.  
  76.         }
  77.  
  78.     }
  79.  
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement