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