#include<iostream>
#define MAXSIZE 100
using namespace std;
typedef int ElemType;
typedef struct
{
ElemType *elem;
int length;
}SqList;
int InitList(SqList &L)
{
L.elem=new ElemType[MAXSIZE];
if(!L.elem)
return -1;
L.length=0;
return 0;
}
void CreatList(SqList &L)
{
int i,n;
cout<<"输入顺序表元素的个数:";
cin>>n;
cout<<"输入元素:";
for(i=0;i<n;i++)
{
cin>>L.elem[i];
L.length++;
}
}
int LocateElem(SqList L,ElemType e)
{
int i;
for(i=0;i<L.length;i++)
{
if(L.elem[i]==e)
return i+1;
}
if(i==L.length)
return -1;
}
int main()
{
ElemType e;
SqList L;
InitList(L);
CreatList(L);
cout<<"请输入要查找的值:";
cin>>e;
cout<<"该元素所在的位置:"<<LocateElem(L,e)<<endl;
}