RE,请帮帮忙
查看原帖
RE,请帮帮忙
1323541
han1219楼主2024/9/19 20:43

代码:

#include<iostream>
#include<stdlib.h>
using namespace std;
int n;
struct node{
	int t;
	node *next;
}*l,*head,*p,*q;; 
int main(){
	cin>>n;
	l=(node *)malloc(sizeof(node));
	l->t=1;
	l->next=NULL;
	head->next=l;
	while(n--){
		int c,x,y;
		cin>>c;
		if(c==1){
			cin>>x>>y;
			p->next=head->next,q=(node *)malloc(sizeof(node));
			while(p->next!=NULL){
				if(p->t==x){
					q->next=p->next;
					q->t=y;
					p->next=q;	
					break;
				}
				p=p->next;
			} 
		}else if(c==2){
			cin>>x;
			p->next=head;
			while(p->next!=NULL){
				if(p->t==x){
					cout<<p->next->t<<endl;
					break;
				}
				p=p->next;
			}
		}else{
			cin>>x;
			p->next=head;
			while(p->next!=NULL){
				if(p->t==x){
					p->next=p->next->next;
					break;
				}
				p=p->next;
			}
		} 
	}
	return 0;
}

然后发生了这样的错误: 好像是RE了,怎么办?

2024/9/19 20:43
加载中...