文章
49
粉丝
90
获赞
90
访问
38.0k
#include<iostream>
#include<queue>
using namespace std;
bool even(int n)
{
return !(n % 2);
}
int main()
{
priority_queue<int, vector<int>, greater<int>> q1, q2;
int n;
cin >> n;
int t;
for (int i = 0; i < n; i++)
{
cin >> t;
if (even(t))
{
q2.emplace(t);
}
else
{
q1.emplace(t);
}
}
while (!q1.empty())
{
cout << q1.top() << " ";
q1.pop();
}
while (!q2.empty())
{
cout << q2.top() << " ";
q2.pop();
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发