为什么全是RE啊 上代码:
#include<stdio.h>
#include<malloc.h>
#define len sizeof(struct node)
int n,m,i=0;
struct node{
int id;
struct node *next;
};
struct node *creat(void){
struct node *head,*p,*q;
scanf("%d%d",&n,&m);
head=(struct node*)malloc(len);
head->next=NULL;
p=head;
while(n-->0){
q=(struct node*)malloc(len);
scanf("%d",&q->id);
q->next=p->next;
p->next=q;
p=q;
}
p->next=NULL;
return head;
}
void research(struct node *head){
struct node *pt;
int target;
head=creat();
pt=head;
for( ;m>=1;m--){
scanf("%d",&target);
while(i!=target){
i++;
pt=pt->next;
}
printf("%d\n",pt->id);
}
}
int main(){
struct node *head;
research(head);
return 0;
}