#include
#include
#define ERROR -40000
using namespace std;
typedef struct LNODE
{
int data;
struct LNODE *next;
}Lnode;
Lnode *Input(int n)
{
Lnode *head,*p,*q;
head=p=(Lnode*)malloc(sizeof(Lnode));
p->next=NULL;
for(int i=0;i
{
int data;
cin>>data;
q=(Lnode*)malloc(sizeof(Lnode));
q->data=data;
q->next=p->next;
p->next=q;
p=q;
}
return head;
}
int FindData(Lnode *L,int id)
{
Lnode *p;
p=L->next;
int j=1;
while(p!=NULL&&j
{
p=p->next;
j++;
}
if(j!=id||p==NULL) return ERROR;//书上没有此处判断n+1位置输入后bug,指针没有分配内存
else return p->data;
}
int main()
{
int n;
while(cin>>n)
{
Lnode *p=Input(n);
cout<
while(1)
{
int num;
cout<
cin>>num;
int find_data=FindData(p,num);
if(find_data!=ERROR)
{
cout<
}
else
{
cout<
}
}
}
return 0;
}