/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* sortEvenOdd(int* nums, int numsSize, int* returnSize){
*returnSize=numsSize;
int b;
for(int a=1;a<numsSize;a=a+2){
for(int c=a+2;c<numsSize;c=c+2){
if(nums[a]<nums[c]){
b=nums[c];
nums[c]=nums[a];
nums[a]=b;
}
}
}
for(int a=0;a<numsSize;a=a+2){
for(int c=a+2;c<numsSize;c=c+2){
if(nums[a]>nums[c]){
b=nums[c];
nums[c]=nums[a];
nums[a]=b;
}
}
}
return nums;
}
力扣------对奇偶下标分别排序
最新推荐文章于 2024-09-02 16:50:54 发布