You are using GCC
#include<iostream>
using namespace std;
struct Node
{
    int data;
    Node* next;
    Node(int d)
    {
        data=d;
        next=NULL;
    }
};
void print(Node* head)
{
    Node* temp=head;
    while(temp!=NULL)
    {
        cout<<temp->data<<" ";
        temp=temp->next;
    }
}
int main()
{
    int n,data,b,e,p,r;
    cin>>n;
    Node* head=NULL;
    Node* tail=NULL;
    for(int i=0;i<n;i++)
    {
        cin>>data;
        Node* obj=new Node(data);
        if(tail==NULL)
        {
            head=obj;
            tail=obj;
        }
        tail->next=obj;
        tail=obj;
    }
    cin>>b>>e>>p>>r;
    Node* obj1=new Node(b);
    obj1->next=head;
    head=obj1;
   Node* obj2=new Node(e);
//   Node* temp=head;
//   while(temp->next!=NULL)
//   {
//       temp=temp->next;
//   }
//   temp->next=obj2;
    tail->next=obj2;
    tail=obj2;
    Node* obj3=new Node(r);
    Node* temp=head;
    for(int i=0;i<p-1&& temp->next!=NULL;i++)
    {
        temp=temp->next;
    }
    obj3->next=temp->next;
    temp->next=obj3;
    print(head);
}