#include <stdio.h>voidreverseArray(int A[], int start, int end){while(start < end){
int temp =A[start];A[start]=A[end];A[end]= temp;
start++;
end--;}}voidexchangeArrays(int A[], int m, int n){reverseArray(A,0, m + n -1);// 整体逆置数组AreverseArray(A,0, n -1);// 逆置前面部分(b1,b2,b3,...,bn)reverseArray(A, n, m + n -1);// 逆置后面部分(a1,a2,a3,...,am)}
int main(){
int m =3;// 第一个线性表的长度
int n =4;// 第二个线性表的长度
int A[]={1,2,3,4,5,6,7,8};// 初始数组printf("交换前的数组:\n");for(int i =0; i < m + n; i++){printf("%d ",A[i]);}printf("\n");exchangeArrays(A, m, n);printf("交换后的数组:\n");for(int i =0; i < m + n; i++){printf("%d ",A[i]);}printf("\n");return0;}