利用快速排序的思想实现左侧为奇数右侧为偶数

#include<stdio.h>
int main()
{
int a[10]={9,6,8,7,0,3,2,4,5,1};

int i=0,j=9;
int tmp;
while(i!=j)
{
while(j>i && a[j]%2==0)
j--;
while(j>i && a[i]%2==1)
i++;
tmp=a[j];
a[j]=a[i];
a[i]=tmp;
}

for( int k=0;k<10;k++)
printf("%d ",a[k]);

}

原文地址:https://www.cnblogs.com/sherlockhomles/p/3089007.html