求教高手顺序表基本操作(C语言)

来源:百度知道 编辑:UC知道 时间:2024/06/07 01:57:31
大概内容
status creatlist(sqlist &l,int n)
{//输入n个数,建立顺序表1
l,elem=(elemtype*)malloc(initsize*sizeof(elemtype));
p=l.elem;
for(i=0;i<n;i++)
scanf(p+i);
l.length=n;
l.listsize=initsize;
return ok;
}
让改成(c语言打出来)

不会

// 00.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "stdlib.h"
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#include <stdio.h>
#include <malloc.h>
typedef char ElemType;
typedef struct{
ElemType *elem;
int length;
int listsize;
}SqList;
int InitList_Sq(SqList &L)
{
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if (!L.elem) return (0);
else
{ L.length=0;
L.listsize=LIST_INIT_SIZE;
return (1);
}
}
void ListInsert_Sq(SqList &L,int i,ElemType e)
{
ElemType *p,*q;
q=L.elem+(i-1);p=L.elem+L.length-1;
for(;p>=q;p--) *(p+1)=*p;
*q=e;
L.length++;
}
void DisplayList(SqList L) // 输出函数
{
int i;
printf("\n");
for(i=1;i<=L.length;i++)
printf(" %d -- %c&