题解
整数奇偶排序
1 条题解
-
0
#include<bits/stdc++.h> using namespace std; bool cmp(int a,int b){ if(a>b){ return true; }else{ return false; } } int main(){ int a,j[11],o[11],x=0,y=0; for(int i=1;i<=10;i++){ cin>>a; if(a%2!=0){ j[++x]=a; }else{ o[++y]=a; } } sort(j+1,j+x+1,cmp); sort(o+1,o+y+1); for(int i=1;i<=x;i++){ cout<<j[i]<<" "; } for(int j=1;j<=y;j++){ cout<<o[j]<<" "; } }
- 1