#include<bits/stdc++.h>
using namespace std;
struct Item
{
int x;
int y;
struct Item *p;
};
typedef struct Item name;
void addMiddle(name *h, name *prev, name *next)
{
name *newNode =
}
void *dlt(name *h,name,int pc)
{
name *temp;
if(h->x == pc)
{
temp = h->p;
free(h);
h = temp;
}
while(h != NULL)
{
if(h->p->x == pc)
{
temp = h->p;
free(h->p);
h->p = temp;
}
h = h->p;
}
}
void addLast(name *h, name *prev)
{
name *newNode = (name *)malloc(sizeof(name));
newNode -> x = 4545;
newNode -> y = 34;
newNode -> p = NULL;
while(h->p)
{
h = h->p; // Moving the node to the last node
}
if(h->p == NULL)
{
h->p = newNode;
}
}
void addFirst(name *h, name *next)
{
name *newNode = (name*)malloc(sizeof(name));
newNode -> x = 444;
newNode -> y =454;
newNode -> p = next;
h = newNode;
}
void printAll(name *s)
{
while(s->p != NULL)
{
printf("%d %d\n",s->x,s->y);
s = s->p;
}
}
name *srchPrev(name *n,int pc)
{
name *temp;
while(n->p)
{
if(n->p->x == pc)
{
temp = n;
break;
}
n = n->p;
}
return temp;
}
name *srch(name *n,int pc)
{
name *temp;
while(n->p)
{
if(n->p->x == pc)
{
temp = n->p;
break;
}
n = n->p;
}
return temp;
}
int main()
{
name *n = (name*)malloc(sizeof(name));
name *head = n;
name *start = n;
name *head2 = n;
/*Starting 2*/
n->x = 45;
n->y = 34;
n->p = (name*)malloc(sizeof(name));
n->p->x = 343; // creating three more node
n->p->y = 4545;
n->p->p = (name*)malloc(sizeof(name));
n->p->p->x = 454;
n->p->p->y = 344;
n->p->p->p = (name*)malloc(sizeof(name));
n->p->p->p->x = 454;
n->p->p->p->y = 344;
n->p->p->p->p = NULL;
printf("%d %d\n",head->x,head->y);
printf("%d %d\n",head->p->x,head->p->y);
printf("%d %d\n",head->p->p->x,head->p->p->y);
/*End 2*/
/*3. Using for loop*/
for(int i=0; i<3; i++)
{
scanf("%d %d",&n->x,&n->y);
n->p = (name*)malloc(sizeof(name));
n = n->p;
}
n->p = NULL;
for(; head2->p != NULL; head2 = head2->p)
{
printf("%d %d\n",head2->x,head2->y);
// head2 = head2->p;
}
/*Ending 3*/
return 0;
}