Advertisement
Josif_tepe

Untitled

Feb 21st, 2025
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 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 kolku_da_dodademe;
  12.     cin >> kolku_da_dodademe;
  13.    
  14.    
  15.     int niza[n + kolku_da_dodademe + 1];
  16.     for(int i = 0; i < n; i++) {
  17.         cin >> niza[i];
  18.     }
  19.     int sz = n;
  20.     for(int i = 0; i < kolku_da_dodademe; i++) {
  21.         int x;
  22.         cin >> x;
  23.        
  24.         for(int j = sz; j > 0; j--) {
  25.             niza[j] = niza[j - 1];
  26.         }
  27.         niza[0] = x;
  28.         sz++;
  29.        
  30.        
  31.     }
  32.    
  33.     for(int i = 0; i < sz; i++) {
  34.         cout << niza[i] << " ";
  35.     }
  36.    
  37.    
  38.    
  39.     return 0;
  40. }
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement