主题:顺序表中元素的删除,帮忙看看
[color=00FF00]下面是一个很简单的在顺序表中删除元素并输出的程序,但我不知道哪里出了错,程序无法执行,大侠们帮忙看看,谢谢![/color]
#include"stdio.h"
#include"malloc.h"
#define overflow -1
#define LIST_INIT_SIZE 30
#define ok 1
#define error 0
typedef struct sqlist{
elemtype *elem;
int length;
int listsize;
}sqlist L,*p;
struct sqlist L.elem[]={1,2,3,4,5,6,7};
struct sqlist L.length=7;
T=(sqlist L*)malloc(30*sizeof(sqlist L));
if(!T) exit(overflow);
int listdelete_sq(sqlist &L,int i,elemtype &e)
{
if(i<1) return error;
if(i>L.length) return error;
p=&(L.elem[i-1]);
e=*p;
q=L.elem+L.length-1;
for(++p;p<=q;++p) *(p-1)=*p;
--L.length;
return ok;
}
main()
{ int e,i,q; sqlist L;
scanf("%d",&i);
e=listdelete_sq(L,i,e);
printf("e=%d",e);
}
#include"stdio.h"
#include"malloc.h"
#define overflow -1
#define LIST_INIT_SIZE 30
#define ok 1
#define error 0
typedef struct sqlist{
elemtype *elem;
int length;
int listsize;
}sqlist L,*p;
struct sqlist L.elem[]={1,2,3,4,5,6,7};
struct sqlist L.length=7;
T=(sqlist L*)malloc(30*sizeof(sqlist L));
if(!T) exit(overflow);
int listdelete_sq(sqlist &L,int i,elemtype &e)
{
if(i<1) return error;
if(i>L.length) return error;
p=&(L.elem[i-1]);
e=*p;
q=L.elem+L.length-1;
for(++p;p<=q;++p) *(p-1)=*p;
--L.length;
return ok;
}
main()
{ int e,i,q; sqlist L;
scanf("%d",&i);
e=listdelete_sq(L,i,e);
printf("e=%d",e);
}