对0 1 2进行 排序
#include <iostream>
#include <cstring>
using namespace std;
const int N = 100010;
int q[N];
void quick_sort(int q[], int l, int r)
{
int red = 0, white = 0, blue = r;
while (l <= r) // 一定要加上等于号
{
if (q[l] == 0)
{
swap(q[l], q[red++]);
l++;
}else if (q[l] == 1)
{
l++;
}else if (q[l] == 2)
{
swap(q[l], q[blue--]);
r--;
}
}
}
int main()
{
int m;
scanf("%d", &m);
for(int i = 0; i < m; i++) scanf("%d", &q[i]);
quick_sort(q, 0, m - 1);
for(int i = 0; i < m; i++) printf("%d ", q[i]);
return 0;
}