1 Star 0 Fork 0

陈泽役 / 小鸿最帅了

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
7-6 银行业务队列简单模拟 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
陈泽役 提交于 2021-04-10 20:26 . add 7-6 银行业务队列简单模拟.
#include<iostream>
#include<queue>
using namespace std;
int main()
{
queue<int> oddQu;
queue<int> evenQu;
int N;
cin >> N;
int i=0;
int num;
int evenLength;
int oddLength;
while(i<N)
{
cin >> num;
if(num%2==0)
{
evenQu.push(num);
}
else
{
oddQu.push(num);
}
i++;
}
int flag=0;
if(oddQu.size()!=1&&evenQu.size()!=1)
{
while(!evenQu.empty()&&!oddQu.empty())
{
if(flag==0)
{
cout << oddQu.front();
flag = 1;
}
else
{
cout<<' '<< oddQu.front();
}
oddQu.pop();
cout<<' '<<oddQu.front();
oddQu.pop();
cout<<' '<<evenQu.front();
evenQu.pop();
}
}
else
{
if(evenQu.size()==1)
{
cout<<evenQu.front();
evenQu.pop();
}
if(oddQu.size()==1)
{
cout<<oddQu.front();
oddQu.pop();
}
}
while(!evenQu.empty())
{
cout<<' '<<evenQu.front();
evenQu.pop();
}
while(!oddQu.empty())
{
cout<<' '<<oddQu.front();
oddQu.pop();
}
return 0;
}
C++
1
https://gitee.com/Yyy1102/xiao-hong-is-the-most-handsome.git
git@gitee.com:Yyy1102/xiao-hong-is-the-most-handsome.git
Yyy1102
xiao-hong-is-the-most-handsome
小鸿最帅了
master

搜索帮助