JosepRivaille

P15030: Control C402E

Apr 23rd, 2015
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.     int n, p, k;
  8.     char c;
  9.     cin >> n >> p >> k >> c;
  10.     vector<string> v(n);
  11.     for (int i = 0; i < n; ++i) {
  12.         cin >> v[i];
  13.     }
  14.     int pos = p;
  15.     if (c == 'd') {
  16.         bool primer = true;
  17.         for (int i = 0; i < k; ++i) {
  18.             ++pos;
  19.             if (pos >= n) pos = 0;
  20.             if (not primer) cout << ' ';
  21.             cout << v[pos];
  22.             primer = false;
  23.         }
  24.     }
  25.     if (c == 'e') {
  26.         bool primer = true;
  27.         for (int i = 0; i < k; ++i) {
  28.             --pos;
  29.             if (pos < 0) pos = n-1;
  30.             if (not primer) cout << ' ';
  31.             cout << v[pos];
  32.             primer = false;
  33.         }
  34.     }
  35.     cout << endl;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment