Josif_tepe

Untitled

Dec 20th, 2025
36
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. int main(){
  4.     int n;
  5.    cin>>n;
  6.    int a[n];
  7.    int b[n];
  8.    int pi=0;
  9.    int ni=0;
  10.    int x;
  11.    for(int i=0; i<n; i++){
  12.        cin>>x;
  13.        if(x%2==0){
  14.            a[pi]=x;
  15.            pi+=1;
  16.        }
  17.        if(x%2!=0){
  18.            b[ni]=x;
  19.            ni+=1;
  20.        }
  21.    }
  22.   for(int i=0; i<pi; i++){
  23.       cout<<a[i]<<" ";
  24.   }
  25.   cout<<endl;
  26.   for(int i=0; i<ni; i++){
  27.       cout<<b[i]<<" ";
  28.   }
  29.  
  30.    return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment