#include<iostream>
using namespace std;
struct Node
{
int data;
Node *next;
};
class LinkList
{
public:
LinkList()
{
head=NULL;
};
void InputList(int );
void PrintList();
private:
Node *head;
};
int main()
{
LinkList list1;
int x;
cout<<"input x you want:"<<endl;
cin>>x;
cout<<"input List:"<<endl;
list1.InputList(x);
list1.PrintList();
}
void LinkList::InputList(int x)
{
int ch;
Node *s,*r;
r=head;
cin>>ch;
while(x--)
{
s=new Node;
s->data=ch;
r->next=s;
r=s;
cin>>ch;
}
r->next=NULL;
}
void LinkList::PrintList()
{
Node *p=head;
p=p->next;
while(p)
{
cout<<p->data<<' ';
p=p->next;
}
}
using namespace std;
struct Node
{
int data;
Node *next;
};
class LinkList
{
public:
LinkList()
{
head=NULL;
};
void InputList(int );
void PrintList();
private:
Node *head;
};
int main()
{
LinkList list1;
int x;
cout<<"input x you want:"<<endl;
cin>>x;
cout<<"input List:"<<endl;
list1.InputList(x);
list1.PrintList();
}
void LinkList::InputList(int x)
{
int ch;
Node *s,*r;
r=head;
cin>>ch;
while(x--)
{
s=new Node;
s->data=ch;
r->next=s;
r=s;
cin>>ch;
}
r->next=NULL;
}
void LinkList::PrintList()
{
Node *p=head;
p=p->next;
while(p)
{
cout<<p->data<<' ';
p=p->next;
}
}
