提交时间:2024-04-26 16:06:26

运行 ID: 46152

#include<bits/stdc++.h> using namespace std; int a[200],b[200]; int main() { int s=0; int t=0; for(int i=0;i<10;i++){ int x; cin>>x; if(x%2!=0){ b[s]=x; s++; } else{ a[t]=x; t++; } } for(int i=0;i<t-1;i++){ for(int j=i+1;j<t;j++){ if(a[j]<a[i]){ int tmp=a[j]; a[j]=a[i]; a[i]=tmp; } } } for(int i=0;i<s-1;i++){ for(int j=i+1;j<s;j++){ if(b[j]>b[i]){ int tmp=b[j]; b[j]=b[i]; b[i]=tmp; } } } for(int i=0;i<t;i++){ cout<<b[i]<<" "; } for(int i=0;i<s;i++){ cout<<a[i]<<" "; } return 0; }