#include<stdio.h>
#include<stdlib.h>
int Re(int a[], int left, int right, int K);
int main(){
int N;scanf("%d",&N);
int *a =(int *)malloc((2*N+1)*sizeof(int));
int i;for(i =0; i <2*N; i++){scanf("%d",&a[i]);}
int median =Re(a,0,2*N-1,N+1);printf("%d", median);return0;}
int Re(int a[], int left, int right, int K){//int j;//for (j = left; j <= right; j++) {// printf("%d ", a[j]);//}//printf("\n");
int l = left, r = right;
int e = a[l];
int t;while(left <= right){if(left == right&&a[left]< e)break;while(left <= right&&a[left]>= e) left++;while(right > left&&a[right]< e) right--;if(left < right){
t = a[left];
a[left]= a[right];
a[right]= t;}}
t = a[left -1];
a[left -1]= a[l];
a[l]= t;//printf("left=%d,right=%d,l=%d,K=%d\n\n", left, right, l, K);if((left -2- l +1)>K-1){returnRe(a, l, left -2,K);}elseif((left -2- l +1)<K-1){returnRe(a, left, r,K-(left -1- l)-1);}elsereturn a[left -1];}
进阶实验1-3.1-两个有序序列的中位数-编程题解题代码测试结果问题整理解题代码#include<stdio.h>#include<stdlib.h>int Re(int a[], int left, int right, int K);int main(){ int N; scanf("%d", &N); int *a = (int *)mall...