Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, i, aux, v[1002], w[1002], a;
- bool ok;
- int main()
- {
- ifstream f("paresort.in");
- ofstream g("paresort.out");
- f >> n;
- for(i = 1; i <= n; i ++)
- {
- f >> v[i];
- if(v[i] % 2 == 0) w[++ a] = v[i];
- }
- if(a == 0) {g << "nu exista"; return 0;}
- do
- {
- ok = true;
- for(i = 1; i < a; i ++)
- if(w[i] > w[i + 1])
- {
- aux = w[i];
- w[i] = w[i + 1];
- w[i + 1] = aux;
- ok = false;
- }
- }while(!ok);
- g << a << "\n";
- for(i = 1; i <= a; i ++)
- g << w[i] << " ";
- return 0;
- }
- Citește mai multe pe Brainly.ro - https://brainly.ro/tema/3020833#readmore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement