#include <the iostream> #include < the malloc .h> the using namespace STD; typedef struct { int length; // save length int Data [ 40 ]; // Array } SqList; / * Algorithm 1: Design of an efficient algorithm, All elements in the reverse order of the table is set, the algorithm requires a degree of how the space shares O (. 1) * / // initialization sequence table void initReverse (S & SqList, int * a, int L) { s.length = 0 ; // insert elements for ( int I = 0 ; I <L; I ++){ s.data[i]=a[i]; } s.length=l; //先输出所有元素 for(int i=0;i<s.length;i++){ cout<<s.data[i]<<" "; } cout<<endl; //逆置 int m=s.length/2; int start=0,end=s.length-1,temp; while(start<end){ temp=s.data [Start]; s.data [Start] = s.data [End]; s.data [End] = TEMP; Start ++ ; End - ; } // Output destruction system and destroyed automatically without operator for ( int I = 0 ; I <s.length; I ++ ) { COUT << s.data [I] << " " ; } COUT << endl; } the using namespace STD; int main () { SqList S; int A [6]={1,2,3,4,5,6}; initReverse(s,a,6); return 0; }