#include<bits/stdc++.h>
using namespace std;
struct Node{
int val;
Node*next;
};
Node*InsertAtBegin(Node*root,int x)
{
Node*newnode=new Node();
newnode->next=NULL;
newnode->val=x;
if(root==NULL)
{
root=newnode;
return root;
}
else
{
newnode->next=root;
root=newnode;
return root;
}
}
void Print(Node*root)
{
Node*currnode;
currnode=root;
while(currnode!=NULL)
{
cout<<currnode->val<<" ";
currnode=currnode->next;
}
cout<<endl;
}
int main()
{
Node*root=NULL;
root=InsertAtBegin(root,3);
root=InsertAtBegin(root,1);
root=InsertAtBegin(root,9);
Print(root);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RydWN0IE5vZGV7CmludCB2YWw7Ck5vZGUqbmV4dDsKfTsKTm9kZSpJbnNlcnRBdEJlZ2luKE5vZGUqcm9vdCxpbnQgeCkKewpOb2RlKm5ld25vZGU9bmV3IE5vZGUoKTsKbmV3bm9kZS0+bmV4dD1OVUxMOwpuZXdub2RlLT52YWw9eDsKaWYocm9vdD09TlVMTCkKewpyb290PW5ld25vZGU7CnJldHVybiByb290Owp9CmVsc2UKewpuZXdub2RlLT5uZXh0PXJvb3Q7CnJvb3Q9bmV3bm9kZTsKcmV0dXJuIHJvb3Q7Cn0KfQp2b2lkIFByaW50KE5vZGUqcm9vdCkKewpOb2RlKmN1cnJub2RlOwpjdXJybm9kZT1yb290Owp3aGlsZShjdXJybm9kZSE9TlVMTCkKewpjb3V0PDxjdXJybm9kZS0+dmFsPDwiICI7CmN1cnJub2RlPWN1cnJub2RlLT5uZXh0Owp9CmNvdXQ8PGVuZGw7Cn0KaW50IG1haW4oKQp7Ck5vZGUqcm9vdD1OVUxMOwpyb290PUluc2VydEF0QmVnaW4ocm9vdCwzKTsKcm9vdD1JbnNlcnRBdEJlZ2luKHJvb3QsMSk7CnJvb3Q9SW5zZXJ0QXRCZWdpbihyb290LDkpOwpQcmludChyb290KTsKfQoK