题目链接:https://codeforces.com/problemset/problem/1251/C
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int t;
cin>>t;
while(t--)
{
vector<int> v1,v2;
string s;
cin>>s;
int len = s.length();
for(int i=0;i<len;i++){
int x = s[i] - '0';
if(x%2)
v1.push_back(x);
else
v2.push_back(x);
}
int i , j;
for(i=0,j=0;i<v1.size()&&j<v2.size();){
if(v1[i] < v2[j])
cout<<v1[i++];
else
cout<<v2[j++];
}
if(i < v1.size()){
for( ; i < v1.size() ; i++)
cout<<v1[i];
}
if(j < v2.size()){
for( ; j < v2.size() ; j++)
cout<<v2[j];
}
cout<<endl;
}
return 0;
}
原文:https://www.cnblogs.com/QFNU-ACM/p/12524112.html