StoneHaos

209

Nov 2nd, 2019
168
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //209
  2. #include <cstdio>
  3. #include <vector>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main(void) {
  8.     FILE* fin = fopen("input.txt", "r");
  9.     FILE* fout = fopen("output.txt", "w");
  10.  
  11.     int n;
  12.     vector<int> a(0);
  13.     vector<int> b(0);
  14.     fscanf(fin, "%d", &n);
  15.     for (int i = 0; i < n; ++ i) {
  16.         int x;
  17.         fscanf(fin, "%d", &x);
  18.         if (x % 2 == 0)
  19.             a.push_back(x);
  20.         else
  21.             b.push_back(x);
  22.     }
  23.     fclose(fin);
  24.     sort(a.begin(), a.end());
  25.     sort(b.begin(), b.end());
  26.     for (int i = 0; i < b.size(); ++ i)
  27.         fprintf(fout, "%d ", b[i]);
  28.     for (int i = a.size() - 1; i >= 0; -- i)
  29.         fprintf(fout, "%d ", a[i]);
  30.     fclose(fout);
  31.     return 0;
  32. }
RAW Paste Data