题解 | #整数奇偶排序#
整数奇偶排序
https://www.nowcoder.com/practice/bbbbf26601b6402c9abfa88de5833163
#include <cstdio>
#include <algorithm>
using namespace std;
bool comp(int x ,int y){
if(x%2==1 && y%2==0){
return true;
}
else if(x%2==1 && y%2==1 && x>y){
return true;
}
else if(x%2==0 && y%2==0 &&x<y){
return true;
}
else{
return false;
}
}
int main(){
int arr[10];
for (int i=0;i<10;i++){
scanf("%d",&arr[i]);
}
sort(arr,arr+10, comp);
for (int i=0;i<10;i++){
printf("%d ",arr[i]);
}
return 0;
}
快手公司福利 1244人发布