Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- #define N 100005
- using namespace std;
- ifstream cin("halfsort3.in");
- ofstream cout("halfsort3.out");
- int v[N];
- int main()
- {
- int n;
- cin >> n;
- for(int i = 1; i <= n; ++ i) cin >> v[i];
- for(int i = 1; i <= n - 1; ++ i)
- {
- for(int j = i + 1; j <= n; ++ j)
- {
- if((v[i] % 2 == 0 and v[j] % 2 == 0 and v[i] > v[j]) or (v[i] % 2 != 0 and v[j] % 2 != 0 and v[i] < v[j]))
- swap(v[i], v[j]);
- }
- }
- for(int i = 1; i <= n; ++ i) cout << v[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement