30分,另外全re
查看原帖
30分,另外全re
1189340
aishiteru_mitsu_ha楼主2024/3/29 19:44
#include<bits/stdc++.h>
using namespace std;
struct node{
	int num;
	node *next;
};
node *p,*h,*r;
int q,way,x,y;
void go_into(node *p,node *h,int x,int y);
void get(node *p,node *h,int x);
void del(node *p,node *h,int x);
int main(){
	h=new node;
	h->num=1;
	r=h;
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>way;
		if(way==1){
			cin>>x>>y;
			go_into(p,h,x,y);
		}else if(way==2){
			cin>>x;
			get(p,h,x);
		}else{
			cin>>x;
			del(p,h,x);
		}
	}
	return 0;
}
void go_into(node *p,node *h,int x,int y){
	node *s;
	s=new node;
	p=h;
	while(p->num!=x){
		p=p->next;
	}
	s->next=p->next;
	s->num=y;
	p->next=s;
}
void get(node *p,node *h,int x){
	p=h;
	while(p->num!=x){
		p=p->next;
	}
	cout<<p->next->num<<endl;
}
void del(node *p,node *h,int x){
	node *s;
	s=new node;
	p=h;
	while(p->num!=x){
		p=p->next;
	}
	s=p->next->next;
	p->next=s;
}
2024/3/29 19:44
加载中...