Advertisement
Josif_tepe

Untitled

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