Advertisement
Josif_tepe

Untitled

Jan 24th, 2025
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 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.    
  14.     int nova_niza[n];
  15.     int idx = 0;
  16.    
  17.     for(int i = 0; i < n; i++) {
  18.         if(niza[i] % 2 == 1) {
  19.             nova_niza[idx] = niza[i];
  20.             idx++;
  21.         }
  22.     }
  23.    
  24.     for(int i = 0; i < idx; i++) {
  25.         cout << nova_niza[i] << " ";
  26.     }
  27.    
  28.    
  29.    
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement