30分求调
查看原帖
30分求调
533635
672760syc楼主2024/3/23 12:47
#include<bits/stdc++.h>
using namespace std;
struct node{
	int v;
	node *next;
};
int main(){
	node *head=new node;
	node *p=head;
	node *r=head;
	head->v=1;head->next=NULL;
	int a,o,x,y;
	cin>>a;
	for(int i=1;i<=a;i++){
		cin>>o;
		if(o==1){
			cin>>x>>y;
			node *newNode=new node;
			newNode->next=NULL;
			while(p!=NULL){
				if(p->v==x){
					newNode->v=y;
					r=p->next;
					p->next=newNode;
					newNode->next=r;
				}
				if(p==NULL){
					newNode->v=y;
					p->next=newNode;
				}
				p=p->next;
			}
			p=head;
			r=head;
		}
		else if(o==2){
			cin>>x;
			while(p!=NULL){
				if(p->v==x){
					cout<<p->next->v<<endl;
				}
				if(p==NULL){
					cout<<"0"<<endl;
				}
				p=p->next;
				
			}
			p=head;
			r=head;
		}
		else{
			cin>>x;
			while(p!=NULL){
				r=p->next;
				if(p->v==x){
					p->next=r->next;
					r->next=NULL;
				}
				p=p->next;
			}
			p=head;
			r=head;
		}
	}
	return 0;
	
}
2024/3/23 12:47
加载中...