Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, i, aux, v[1002], w[1002], a;
  4. bool ok;
  5. int main()
  6. {
  7.     ifstream f("paresort.in");
  8.     ofstream g("paresort.out");
  9.     f >> n;
  10.     for(i = 1; i <= n; i ++)
  11.     {
  12.         f >> v[i];
  13.         if(v[i] % 2 == 0) w[++ a] = v[i];
  14.     }
  15.     if(a == 0) {g << "nu exista"; return 0;}
  16.     do
  17.     {
  18.         ok = true;
  19.         for(i = 1; i < a; i ++)
  20.         if(w[i] > w[i + 1])
  21.         {
  22.             aux = w[i];
  23.             w[i] = w[i + 1];
  24.             w[i + 1] = aux;
  25.             ok = false;
  26.         }
  27.     }while(!ok);
  28.     g << a << "\n";
  29.     for(i = 1; i <= a; i ++)
  30.     g << w[i] << " ";
  31.     return 0;
  32. }
  33.  
  34.  
  35. Citește mai multe pe Brainly.ro - https://brainly.ro/tema/3020833#readmore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement