为什么printh函数不能调用,locateelem调用结果有错误,谢谢大家

#include
using namespace std;
#include
#include
#define list_init_size 100
#define listincrement 10
typedef int elemtype;
typedef struct{
elemtype elem;
int length;
int listsize;
}Sqlist;
int initlist(Sqlist &L)
{
L.elem=(elemtype *)malloc(list_init_size*sizeof(elemtype));
if(!L.elem) exit(-1);
L.length=0;
L.listsize=list_init_size;
return 0;
}
int listinsert(Sqlist &L,int i,elemtype e)
{
int *newbase,*p,*q;
if(iL.length+1) return -1;
if(L.length>=L.listsize)
{
newbase=(int
)realloc(L.elem,(L.listsize+listincrement)*sizeof(elemtype));
if(!newbase) exit(-1);
L.elem=newbase;
L.listsize+=listincrement;
}
q=L.elem+i-1;
for(p=L.elem+L.length-1;p>=q;--p)
{
*(p+1)=*p;
*q=e;
++L.length;
}
}
int locatelem(Sqlist L,elemtype e)
{
int *p;
p=L.elem;
int i;
while(i<=L.length&&(*p++!=e))
++i;
if(i<=L.length)
return i;
else
return 0;
}
int listdelete(Sqlist &L,int i,elemtype &e)
{
int *p,*q;
if((iL.length)) return -1;
p=&(L.elem[i-1]);
e=*p;
q=L.elem+L.length-1;
for(++p;p<=q;++p) *(p-1)=*p;
--L.length;
return 0;
}
void print(Sqlist L)
{
int i;
for(i=0;i {
printf("%d",L.elem[i]);
}
// printf("\n");
}
int main()
{
Sqlist L;
elemtype e;
int i,n,t;
initlist(L);
cout cin>>n;
for(i=1;i<=n;i++)
{
cin>>e;
listinsert(L,i,e);
}
cout<<"目前表中的元素:";
print(L);
cout<<"你要查询的元素:";
cin>>e;
i=locatelem(L,e);
cout< cout cin>>i;
t=listdelete(L,i,e);
if(t==0)
cout<<"删除第"<<i<<"个元素失败"<<endl;
else
cout<<"删除第"<<i<<"个元素值为"<<e<<endl;
cout<<"目前表中元素";
print(L);
return 0;
}