Dynamically assigned codes for sequence tables

顺序表的建表:
typedef  int  KeyType;
typedef  struct {
    
                          
  KeyType *elem; /*elem[0]一般作哨兵或缓冲区*/                       
  int Length;      
}SqList;

顺序表的动态分配:
void  CreatSqList(SqList *L)//待排序列建立,由裁判实现,细节不表
{
    
    
	int i = 1;
	 L->elem = (KeyType *)malloc(sizeof(KeyType));
	 L->Length = 0;
	int x;
	scanf("%d", &x);
	while (i <= x)
	{
    
    
		scanf("%d", &L->elem[i]);
		L->Length++;
		i++;
	}
}

Guess you like

Origin blog.csdn.net/hx_521/article/details/92434490