Sequence table creation and in-place inverse (function)

This topic requires the creation of a sequence table and an in-place inverse operation function. L is a sequence table, the function ListCreate_Sq(SqList &L) is used to create a sequence table, and the function ListReverse_Sq(SqList &L) reverses the elements in the sequence table without introducing an auxiliary array, such as the original sequence table element. For 1, 2, 3, 4, the inverse is 4, 3, 2, 1.

function interface definition:

Status ListCreate_Sq(SqList &L);
void ListReverse_Sq(SqList &L);

裁判test program example:

// library function header file contains

/ / Function status code definition
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2

Typedef int Status;

/ / Sequence table storage structure definition
#define LIST_INIT_SIZE 100
Typedef int ElemType; // Assume that the elements in the linear table are all integers
Typedef struct{
    ElemType* elem; / / storage space base address
    Int length; / / the number of elements in the table
    Int listsize; / / table size
}SqList; //Sequence table type definition

Status ListCreate_Sq(SqList &L);
Void ListReverse_Sq(SqList &L);

Int main() {
    SqList L;
    ElemType *p;

    If(ListCreate_Sq(L)!= OK) {
        Printf("ListCreate_Sq: creation failed!!!\n");
        Return -1;


Printf("%d ",*p);
    Return 0;
/* Please fill in the answer here */

Input format: The first line enters an integer n, indicating the number of elements in the sequence table. The next n integers are table elements separated by spaces. output format: Outputs the elements of the sequence table after the inverse, separated by spaces between the two elements, and there is no space after the last element.


1 2 3 4


4 3 2 1
Status ListCreate_Sq(SqList &L)
    int n;
    return FALSE;
    L.elem =new ElemType[n+1];
        return ERROR;
    L.length =n;
    for(int i=0;i<n;i++)
    return OK;
void ListReverse_Sq(SqList &L)
    for(int i=0;i<L.length/2;i++)
        int t=L.elem[i];
    return ;