Advertisement
Josif_tepe

Untitled

Jan 24th, 2025
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.     cin >> n;
  8.    
  9.     int niza[n];
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> niza[i];
  12.     }
  13.     int K;
  14.     cin >> K;
  15.    
  16.     int res[n];
  17.    
  18.     for(int i = 0; i < n; i++) {
  19.         int new_idx = (i + K) % n;
  20.         res[new_idx] = niza[i];
  21.     }
  22.    
  23.     for(int i = 0; i < n; i++) {
  24.         cout << res[i] << " ";
  25.     }
  26.    
  27.    
  28.    
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement