#include <stdio.h>
int fun(int a[], int n, int b[], int m, int c[])
{
int i = 0, j = m - 1, k = 0;
while(i < n && j >= 0)
c[k++] = a[i] < b[j] ? a[i++] : b[j--];
while(i < n)
c[k++] = a[i++];
while(j >= 0)
c[k++] = b[j--];
return k;
}
int main()
{
int a[5] = {1, 4, 7, 11, 12}, b[5] = {15, 13, 10, 6, 5}, c[20];
int i, n;
printf("数组a的元素:\n");
for(i = 0; i < 5; i++)
printf("%d ", a[i]);
printf("\n");
printf("数组b的元素:\n");
for(i = 0; i < 5; i++)
printf("%d ", b[i]);
printf("\n");
n = fun(a, 5, b, 5, c);
printf("合并后数组c的元素:\n");
for(i = 0; i < n; i++)
printf("%d ", c[i]);
return 0;
}