#include <iostream>
using namespace std;
void sort3p(int *x, int len)
{
    int p = 0;
    int left = 0;
    int right = len - 1;

    while (p <= right)
    {
        if (x[p] < 0)
        {
            int t = x[left];
            x[left] = x[p];
            x[p] = t;
            left++;
            p++;
        }
        else if (x[p] > 0)
        {
            int t = x[right];
            x[right] = x[p];
            x[p] = t;
            right--;
        }
        else
        {
            p++; //填空位置
        }
    }
}
int main()
{
    int a[10] = {0, -1, 0, 0, -2, 5, 3, 1, 0, 7};
    sort3p(a, 10);
    for (int i = 0; i < 10; i++)
    {
        printf("%d ", a[i]);
    }
    return 0;
}