在网站用什么做页面布局,网站做语言切换,传奇网游游戏排行榜,广告设计与制作专升本考试科目思路#xff1a;
#xff08;1#xff09;注意到总体规律是奇数不能跨越奇数#xff0c;偶数不能跨越偶数
#xff08;2#xff09;冒泡不可取#xff1b;
#xff08;3#xff09;直接队列分别存奇偶#xff0c;小的往前放就行。
代码#xff1a;
#include
1注意到总体规律是奇数不能跨越奇数偶数不能跨越偶数
2冒泡不可取
3直接队列分别存奇偶小的往前放就行。
代码
#includebits/stdc.h
using namespace std;int main()
{int t;cin t;cin.tie(0);while(t --){string x;cin x;queuechar a,b;for(int i 0;i x.size();i )if((x[i]- 0) % 2 0)a.push(x[i]);else b.push(x[i]);string res ;while(!a.empty() !b.empty()){if(a.front() b.front()){res b.front();b.pop();}else{res a.front();a.pop();}}while(!a.empty()){res a.front();a.pop();}while(!b.empty()){res b.front();b.pop();}cout res endl; }return 0;
}