1 Star 0 Fork 0

章审 / 章审的高压锅777

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
7-6 银行业务队列简单模拟 904 Bytes
Copy Edit Raw Blame History
章审 authored 2021-04-05 19:59 . add 7-6 银行业务队列简单模拟.
#include <iostream>
#include <queue>
using namespace std;
int main()
{
int i, n, k;
cin >> k;
queue<int> q1;
queue<int> q2;
for (i = 0; i < k; i++)
{
cin >> n;
if (n % 2)
{
q1.push(n);
}
else
{
q2.push(n);
}
}
for (i = 0; i < k; i++)
{
if (i == 0)
{
if (!q1.empty())
{
cout << q1.front();
q1.pop();
}
else
{
cout << q2.front();
q2.pop();
}
continue;
}
if ((i + 1) % 3)
{
if (!q1.empty())
{
cout << " " << q1.front();
q1.pop();
}
else
{
while (!q2.empty())
{
cout << " " << q2.front();
q2.pop();
}
}
}
else
{
if (!q2.empty())
{
cout << " " << q2.front();
q2.pop();
}
else
{
while (!q1.empty())
{
cout << " " << q1.front();
q1.pop();
}
}
}
}
return 0;
}
1
https://gitee.com/z202021123020/zs777.git
git@gitee.com:z202021123020/zs777.git
z202021123020
zs777
章审的高压锅777
master

Search