#include <iostream>
#include <stdio.h>
using namespace std;
int g_szArray[] = { 7, 3, 5, 8, 9, 1, 2, 4, 6 };
void main()
{
int nLen = sizeof(g_szArray) / sizeof(g_szArray[0]);
int nStep = nLen / 2;
while (nStep >= 1)
{
for (int i = 0; i < nLen; i++)
{
if (i + nStep > nLen - 1)
{
break;
}
if (g_szArray[i] > g_szArray[i + nStep])
{
g_szArray[i] = g_szArray[i] + g_szArray[i + nStep];
g_szArray[i + nStep] = g_szArray[i] - g_szArray[i + nStep];
g_szArray[i] = g_szArray[i] - g_szArray[i + nStep];
}
}
nStep = nStep / 2;
}
for (int i = 0; i < nLen; i++)
{
printf("%d ", g_szArray[i]);
}
printf("\n");
system("pause");
}