LeetCode的复习(03)
#include <stdio.h>#define M 2
#define N 1
int main(void) {
int nums1 = {1,3};
int nums2 = {2};
int nums3 = {0};
int i, j, k, in = 0, mid_index = 0;
float mid = 0.0;
int temp,num2 = 0,num1 = 0;
if(nums1 == nums2-1)
{
mid = ((float)(nums1+nums2))/2;
}else{
mid_index = (M+N)/2;
j = 0;
if(M>N)
{
while(j<M)
{
nums3 = nums1;
j += 1;
in += 1;
}
for(k = 0;k<N;k++)
{
j = 0;
num2 = nums2;
while(num2>nums1) j+=1;
temp = j;
for(in = N+M;in>=j;in--) nums3 = nums3;
nums3 = num2;
}
mid = ((float)(nums3+nums3))/2;
}
}
printf("mid = %.2f\n",mid);
return 0;
}
题目:
两个有序数组的中位数
页:
[1]