#include
using namespace std;
class node{
public:
int data;
node* next;
node(int d)
{
this->data=d;
}
};
void push(nodehead,int data)
{
nodea=new node(data);
node*temp=head;
a->next=head;
if(head!=NULL)
{
while(temp->next!=head)
{
temp=temp->next;
}
temp->next=a;
}
else
{
a->next=a;
}
head=a;
}
void print(nodehead)
{
nodetemp=head;
while(temp->next!=head)
{
cout<data<<" <- ";
temp=temp->next;
}
cout<data<<“END”;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen(“input.txt”,“r”,stdin);
freopen(“output.txt”,“w”,stdout);
#endif
node*head=NULL;
push(head,2);
push(head,3);
push(head,10);
push(head,30);
push(head,40);
print(head);
cout<<endl;
return 0;
}