SHARE
TWEET

sapXep chanLe

a guest Oct 21st, 2019 92 in 2 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.    
  11.     vector<int>num(n);
  12.     vector<int>numO(n);
  13.     vector<int>numE(n);
  14.  
  15.     int a = 0, b = 0;
  16.  
  17.     for (int i = 0; i < n; i++) {
  18.         cin >> num[i];
  19.         if (num[i] % 2 == 0) {
  20.             numE[a] = num[i];
  21.             a++;
  22.         }
  23.         else {
  24.             numO[b] = num[i];
  25.             b++;
  26.         }
  27.     }
  28.     numE.resize(a);
  29.     numO.resize(b);
  30.     sort(numE.begin(), numE.end());
  31.     sort(numO.begin(), numO.end());
  32.  
  33.     for (int i = 0; i < a; i++) {
  34.         cout << numE[i] << " ";
  35.     }
  36.  
  37.     for (int i = b-1 ; i >=0; i--) {
  38.         cout << numO[i] << " ";
  39.     }
  40.    
  41.  
  42.     return 0;
  43.  
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top