文章
1
粉丝
37
获赞
0
访问
391
1010排序
Time Limit: 1000 ms
Memory Limit: 256 mb
输入n个数进行排序,要求先按奇偶后按从小到大的顺序排序
代码如下:
#include <stdio.h>
int Partition1(int a[], int low, int high){
int pivot=a[low];
while(low<high){
while(low<high&&a[high]%2==0)
high--;
a[low]=a[high];
while(low<high&&a[low]%2!=0)
low++;
a[high]=a[low];
}
a[low]=pivot;
return low;
}
int Partition2(int a[], int low, int high){
int pivot=a[low];
while(low<high){
while(low<high&&a[high]>=pivot)
...
登录后发布评论
主函数直接以mid划分感觉有点问题,奇偶应该有区别