【程序练习】——线性表有序合并
1 #include<stdio.h> 2 #define MAX 20 3 int main() 4 { 5 int a[4] = {3,5,8,11}; 6 int b[7] = {2,6,8,9,11,15,20}; 7 int i = 0,j = 0; 8 int c[MAX]; 9 int tmp = 0; 10 11 while(i < 4 && j < 7){ 12 if(a[i] < b[j]) 13 c[tmp++] = a[i++]; 14 else 15 c[tmp++] = b[j++]; 16 } 17 18 while(i < 4) 19 c[tmp++] = a[i++]; 20 21 while(j < 7) 22 c[tmp++] = b[j++]; 23 24 for(i = 0; i < 11; i++) 25 printf("%d\t",c[i]); 26 }