Codeforces Round #563 (Div. 2)B;Ehab Is an Odd Person

原文链接:任意门

题目大意:给你一组数,让你交换两个数的位置,让它们的和为奇数,且使其交换后,顺序满足最小字典序列。
思路:这就是一道狗题,看代码,你就会******了,只需要sort排序。
代码:

 1 #include"iostream"
 2 #include"algorithm"
 3 #include"cstdio"
 4 #include"cstring"    
 5 long long a[10000006],n,js=0,os=0;
 6 using namespace std;
 7 int main(){
 8     std::ios::sync_with_stdio(false);
 9     cin>>n;
10     for(int i=0;i<n;i++) {
11         cin>>a[i];
12         if(a[i]%2!=0) js++;
13         else{
14             os++;
15         }
16     }
17     if(js!=0&&os!=0) sort(a,a+n);
18     for(int i=0;i<n;i++){
19         cout<<a[i];
20     if(i!=n-1){
21         cout<<" ";
22       }
23      }
24      return 0;
25 }
原文地址:https://www.cnblogs.com/huangdf/p/12222908.html