线性表的调用函数问题
# include<stdio.h>#define OK 1
#define ERROR 0
#define MAXSIZE 100
typedef int ElemType;
typedef int status;
typedef struct SqList
{ ElemType *elem;
int length;
}SqList;
status creatlist(SqList &L,int n)
{
//创建线性表
int i;
L.elem=new ElemType[MAXSIZE];
if(!L.elem) return ERROR;
L.length=n;
printf(" Input the element: ");
for(i=0;i<L.length;i++) scanf("%d",&L.elem[i]);
printf(" The created list as follow: ");
for(i=0;i<L.length;i++) printf("%d ",L.elem[i]);
printf("\n");
return OK;
}
int LocateElem(SqList L,ElemType e)
{
//查找位序
int z;
for(z=0;z<L.length;z++)
if(L.elem[z]==e)
{ return z+1;
printf("%d",z+1);
}
else
{ return 0;
printf("输入值错误");
}
}
int main()
{
int LocateElem(SqList L,ElemType e);
SqList sq;int x;
int y;
printf("element num: ");
scanf("%d",&x);
creatlist(sq,x);
printf("请输入要查找的值");
scanf("%d",&y);
LocateElem(sq,y);
return 0;
}
我的查找位序函数无法调用,请问这是怎么回事?