#include<bits/stdc++.h>
using namespace std;
struct Node{
int val;
Node*next;
};
Node*InsertAtEnd(Node*root,int x)
{
Node*newnode=new Node();
newnode->val=x;
newnode->next=NULL;
if(root==NULL)
{
root=newnode;
return root;
}
Node*currnode;
currnode=root;
while(currnode->next!=NULL)
{
currnode=currnode->next;
}
currnode->next=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=InsertAtEnd(root,7);
root=InsertAtEnd(root,5);
Print(root);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RydWN0IE5vZGV7CmludCB2YWw7Ck5vZGUqbmV4dDsKfTsKTm9kZSpJbnNlcnRBdEVuZChOb2RlKnJvb3QsaW50IHgpCnsKTm9kZSpuZXdub2RlPW5ldyBOb2RlKCk7Cm5ld25vZGUtPnZhbD14OwpuZXdub2RlLT5uZXh0PU5VTEw7CmlmKHJvb3Q9PU5VTEwpCnsKcm9vdD1uZXdub2RlOwpyZXR1cm4gcm9vdDsKfQpOb2RlKmN1cnJub2RlOwpjdXJybm9kZT1yb290Owp3aGlsZShjdXJybm9kZS0+bmV4dCE9TlVMTCkKewpjdXJybm9kZT1jdXJybm9kZS0+bmV4dDsKfQpjdXJybm9kZS0+bmV4dD1uZXdub2RlOwpyZXR1cm4gcm9vdDsKfQp2b2lkIFByaW50KE5vZGUqcm9vdCkKewpOb2RlKmN1cnJub2RlOwpjdXJybm9kZT1yb290Owp3aGlsZShjdXJybm9kZSE9TlVMTCkKewpjb3V0PDxjdXJybm9kZS0+dmFsPDwiICI7CmN1cnJub2RlPWN1cnJub2RlLT5uZXh0Owp9CmNvdXQ8PGVuZGw7Cn0KaW50IG1haW4oKQp7Ck5vZGUqcm9vdD1OVUxMOwpyb290PUluc2VydEF0RW5kKHJvb3QsNyk7CnJvb3Q9SW5zZXJ0QXRFbmQocm9vdCw1KTsKUHJpbnQocm9vdCk7Cn0KCg==