#include
#include
#include
using namespace std;
void Adjust(vector& s)
{
int i, j;
i = 0; j = s.size() - 1;
cout << s.size() << endl;
while (i < j)
{
while ( (s[i] % 2 == 1) && (i < j))
i++;
while ( (s[j] % 2 == 0) && (i < j))
j--;
//swap them
int t = s[i];
s[i] = s[j];
s[j] = t;
}
}
int main()
{
vector t;
int i, j;
cin >> i;
for (int x = 0; x < i; x++) {
cin >> j;
t.push_back(j);
}
for (i = 0; i < t.size(); i++)
cout << t[i];
cout << endl;
Adjust(t);
for (i = 0; i < t.size(); i++)
cout << t[i];
cout << endl;
return 0;
}
排序,奇前偶后
最新推荐文章于 2023-01-11 09:30:00 发布
9万+

被折叠的 条评论
为什么被折叠?



