AcWing 3638. 排序
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e3+10;
int t,n,m,k,l,r,op,x,y;
int f1[N],s1,f2[N],s2;
void solve(){
cin>>n;
for(int i = 1;i<=n;i++){
cin>>t;
if(t%2)f1[++s1]=t;
else f2[++s2]=t;
}
sort(f1+1,f1+1+s1);
sort(f2+1,f2+1+s2);
for(int i = 1;i<=s1;i++){
cout<<f1[i]<<" ";
}
for(int i = 1;i<=s2;i++){
cout<<f2[i]<<" ";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}