利用线性表插入,怎样在数组插入元素
#define LIST_INIT_SIZE 100#define LISTINCREMENT 10
#include<stdio.h>
#include<malloc.h>
typedef struct
{
char *elem;
int length;
int Listsize;
}SqList;
int InitList Sq(struct &L);
int ListTnsert_Sq(struct &L,int i,char e);
void main
{
SqList aa[n];
printf("输入待插入数组:\n");
for(int s=0;s<n;s++)
scanf("%c",&aa[s]);
InitList_Sq(aa[n]);
ListInsert_Sq(aa[n],int i=4,char add='z');
for(int j=0;j<n+1;j++)
printf("%c",aa[i]);
return 0;
}
int InitList Sq(struct &L){
L.elem=(char *)malloc(LIST_INIT_SIZE *sizeof(char);
if(!L.elem)return -2;
l.length=0;
L.listsize=LIST_INIT_SIZE;
return 1;
}
int ListInsert_Sq(struct &L,int i,char e)
{
if(i<i || i>L.length+1)return 0;
if(L.length>=L.listsize){
int newbase=(char *)realloc(L.elem,(L.listsize+LISTINCREMENT)*sizeof(char));
if(!newbase)return -2;
L.elem=newbase;
L.listsize+=LISTINCREMENT;
}
int *q=&(L.elem[i-1]);
int *p;
for(p=&(L.elem[L.length-1]);p>=q;--p)*(p+1)=*p;
*q=e;
++(L.length);
return 1;
}
以上是基本的代码,在VC++ 6.0 运行中出现了以下错误:
cpp(11) : error C2146: syntax error : missing ';' before identifier 'Sq'
D:\VC++6.0\MSDev98\MyProjects\gg\数据结构1\插入.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
我该怎么弄啊,请教!