考研 线性表 王道第8题

void List_to_Array(int a[],int len,SqList* L, SqList* L1){

	int j = 0;
	int i = 0;
    	for(i=0;i<20;i++){
    		if(i<L->length)
           		 a[i]=L->data[i];
           	if(i>=L->length && j<L1->length)
           		 a[i]=L1->data[j++];
    	}
}

void Reverse(int a[],int l, int r){
	
    int mid = (l+r)/2;
    for(int i = 0; i < mid;i++){
    	int temp = a[i];
        a[l+i] = a[r-i];
        a[r-i] = temp; 
    }
}

void exchange(int a[], int m, int n){
	
    Reverse(a,0,m+n-1);
    Reverse(a,0,n-1);
    Reverse(a,n,m+n-1);
 }




你可能感兴趣的:(数据结构复习,线性表,考研)