|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#define M 2
#define N 1
int main(void) {
int nums1[M] = {1,3};
int nums2[N] = {2};
int nums3[M+N] = {0};
int i, j, k, in = 0, mid_index = 0;
float mid = 0.0;
int temp,num2 = 0,num1 = 0;
if(nums1[M-1] == nums2[0]-1)
{
mid = ((float)(nums1[M-1]+nums2[0]))/2;
}else{
mid_index = (M+N)/2;
j = 0;
if(M>N)
{
while(j<M)
{
nums3[in] = nums1[j];
j += 1;
in += 1;
}
for(k = 0;k<N;k++)
{
j = 0;
num2 = nums2[k];
while(num2>nums1[j]) j+=1;
temp = j;
for(in = N+M;in>=j;in--) nums3[in] = nums3[in-1];
nums3[temp] = num2;
}
mid = ((float)(nums3[mid_index]+nums3[mid_index+1]))/2;
}
}
printf("mid = %.2f\n",mid);
return 0;
}
|
|