一个刚学指针链表的蒟蒻写的 大佬们的题解都看不懂只能请教板块高手力(悲)
#include <bits/stdc++.h>
using namespace std;
struct Node{
int no;
Node *next,*last;
}*head;
int main(){
head=new(Node);
head->no=0,head->next=NULL;
Node *p=head;
int n,m;
cin>>n;
for(int i=2;i<=n;i++)
{
int a,b;
cin>>a>>b;
Node *q=new(Node);
if(b==1){
q->no=i,q->next=NULL;
p->next=q,p=q;
}
else
{
q->no=i,q->last=NULL;
p->last=q,p=q;
}
}
cin>>m;
for(int i=1;i<=m;i++)
{
int a;
cin>>a;
for(Node *q=head->next;q!=NULL;q=q->next)
{
if(q->no==a)
{
(q-1)->next=q->next;
}
}
}
for(Node *q=head->next;q!=NULL;q=q->next)
{
cout<<q->no<<" ";
}
return 0;
}