eolymp
bolt
Try our new interface for solving problems
Məsələlər

Сортировка четных и нечетных

dərc olunub 14.01.24 15:15:47

include <bits/stdc++.h>

using namespace std;

define ll long long

int main(){ ll n,cnt=0; cin>>n; ll a[n]; for(ll i =0;i<n;i++){ cin>>a[i]; } sort(a,a+n); for (int i = 0;i<n;i++){ if (a[i]%2!=0){ cout<<a[i]<<' '; }

}
for (int i =n-1;i>=0;i--){
    if (a[i]%2==0){
        cout<<a[i]<<' ';
    }
}

}