#include
using namespace std;
class list
{
public:
list* head;
list* tail;
list* next;
list* t;
int x;
list()
{
head=tail=NULL;
}
};
class set:public list
{
private:
int size;//元素个数
public:
void get()
{
t=new list;
cin>>t->x;
t->next=NULL;
while(t->next!=0)
{
tail->next=t;
tail=t;
t=new list;
cin>>t->x;
t->x=NULL;
}
}
set(int size):list()
{
this->size=size;
}
void search(int m)
{
for(int i=0;i<size;i++)
{
if(t->x==m)
{
cout<<"查找到第"<<i+1<<"位"<<endl;
}
t=t->next;
}
}
void add(int m)
{
t=new list;
t=head;
size++;
while(t)
{
tail->next->x=m;
}
}
void del(int m)
{
list *x=new list;
t=new list;
t=head;
while(t->next!=NULL)
{
if(t->next->x==m)
{
t->next=t->next->next;
}
else
t=t->next;
}
}
void show()
{
t=head;
while(t!=NULL)
{
cout<<t->x<<" ";
t=t->next;
}
cout<<endl
}
};
int main()
{
list l;
set s(3);
s.get();
s.search(1);
s.show();
s.add(2);
s.del(3);
}