这个tmd我傻了老是给我RE老脸都丢没了
#include<bits/stdc++.h>
using namespace std;
int a[30000000];
struct Boe
{
int x;
Boe *next;
};
struct danlink
{
Boe *first;
danlink(){
first=new Boe;
first->next=NULL;
}
danlink(int *a,int n){
first=new Boe;
first->next=NULL;
Boe *last=first;
for(int i=1;i<=n;i++){
Boe *y=new Boe;
y->x=a[i];
last->next=y;
last=y;
}
last->next=NULL;
}
danlink(int *a,int n,int o){
first=new Boe;
first->next=NULL;
for(int i=1;i<=n;i++){
Boe *x=new Boe;
x->x=a[i];
x->next=first->next;
first->next=x;
}
}
~danlink(){
for(Boe *i=first->next;i;)
{
Boe *x=i;
i=i->next;
delete x;
}
delete first;
}
void print()
{
for(Boe *i=first->next;i;i=i->next)
cout<<i->x<<' ';
cout<<endl;
return;
}
bool place(int w){
int flag=0;
Boe *x=first;//就这我给弄成first->next了然后突然明白试了试删除第一个位置的还真不行了。啊啊啊谨记谨记
for(Boe *i=first->next;i;x=i,i=i->next)
{
flag++;
if(flag==w)
{
x->next=i->next;
delete i;
return 1;
}
}
return 0;
}
bool valuee(int v){
Boe *x=first;
for(Boe *i=first->next;i;x=i,i=i->next)
{
if(i->x==v)
{
x->next=i->next;
delete i;
return 1;
}
}
return 0;
}
};
int main()
{
int i=0,n;
while(cin>>n,n)
{
a[++i]=n;
}
danlink l(a,i);
i=0;
while(cin>>n,n)
{
a[++i]=n;
}
danlink m(a,i,0);
int p,q;
cin>>p>>q;
l.print();
m.print();
if(l.valuee(p))
{
l.print();
}
else
cout<<"Error"<<endl;
if(l.place(q))
l.print();
else
cout<<"Error"<<endl;
return 0;
}