Tuesday 30 August 2016

Saddle Point Matrix Operation

Group A: Assignment No :03 (SPPU Syllabus Assignment No: 08)
Problem Statement:
An m x n matrix is said to have a saddle point if some entry a[i][j] is the smallest value in row i and the largest value in j. Write C/ C++ function that determines the location of a saddle point if one exists.

Program code:

//Group A: Assignment no : 03
//Author:NMS
//Title: Saddle point

#include<iostream>
using namespace std;

class smat
{
  int mat[10][10],i,j,row,col,min,max; //data memebers
 public:
  smat() //default constructor
  {
   i=j=row=col=0;
   min=max=0;
  }
  void getdata(); //member functions
  void showmat();
  void saddlepoint();

};//end of class smat

void smat::getdata() //To accept matrix element
{
 cout<<"\n Enter How many Rows in matrix: ";
 cin>>row;
 cout<<"\n Enter How many cols in matrix: ";
 cin>>col;
 for(i=0;i<row;i++)
 {
  for(j=0;j<col;j++)
  {
   cout<<"\nEnter matrix mat["<<i<<"]["<<j<<"] element : ";
   cin>>mat[i][j];
  }
 }
}

void smat::showmat()//To show elements inside the matrix.
{
 cout<<"\nThe Elements inside the matrix are as follows...\n\n";
 for(i=0;i<row;i++)
 {
  for(j=0;j<col;j++)
  {
   cout<<"\t"<<mat[i][j];
  }
  cout<<"\n";
 }
 cout<<"\n";
}

void smat::saddlepoint()
{
 int big[5],small[5];
 for(i=0;i<5;i++)
 {
  big[i]=small[i]=0; //intialize two arrays with value zero.
 }
 //To find out the smallest value in row i
 for(i=0;i<row;i++)
 {
  small[i]=mat[i][0];
  for(j=0;j<col;j++)
  {
     if(mat[i][j]<=small[i])
     {
      small[i]=mat[i][j];
     }
  }
 }
 // To find out the Largest value in column j
 for(j=0;j<col;j++)
 {
  big[j]=mat[0][j];
  for(i=0;i<row;i++)
  {
   if(mat[i][j]>=big[j])
   {
    big[j]=mat[i][j];
   }
  }
 }
 // To fin out the largest from small array in row
 max=small[0];
 for(i=0;i<row;i++)
 {
  if(small[i]>=max)
  {
   max=small[i];
  }
 }
 //To find out smallest from the big array in col.
 min=big[0];
 for(j=0;j<col;j++)
 {
  if(big[j]<=min)
  {
   min=big[j];
  }
 }
 // Now compaire both min & max if both same then saddle point is there else not.
 if(min==max)
 {
  cout<<"\nSaddle point "<<min<<" is present in the array\n\n";
 }
 else
 {
  cout<<"\nSaddle point is not present in given matrix...\n\n";
 }
}

int main()
{
 smat s1;
 s1.getdata();
 s1.showmat();
 s1.saddlepoint();
 return 0;
}

/*************************************************************************************
[student@localhost Documents]$ g++ saddle.cpp
[student@localhost Documents]$ ./a.out

 Enter How many Rows in matrix: 3

 Enter How many cols in matrix: 3

Enter matrix mat[0][0] element : 9

Enter matrix mat[0][1] element : 8

Enter matrix mat[0][2] element : 7

Enter matrix mat[1][0] element : 6

Enter matrix mat[1][1] element : 5

Enter matrix mat[1][2] element : 4

Enter matrix mat[2][0] element : 3

Enter matrix mat[2][1] element : 2

Enter matrix mat[2][2] element : 1

The Elements inside the matrix are as follows...

    9    8    7
    6    5    4
    3    2    1


Saddle point 7 is present in the array

[student@localhost Documents]$

***************************************************************************************/

Class Test operation using C++

Group A : Assignment No: 02 (SPPU Syllabus Assignment No: 02)
Problem Statement: 
Write C/C++ program to store marks scored for first test of subject 'Data Structures and Algorithms' for N students. Compute
I. The average score of class
ii. Highest score and lowest score of class
iii. Marks scored by most of the students
iv. list of students who were absent for the test

Program Code: (Implementation)

//============================================================================
// Name        : Test.cpp
// Author      : Nitin Shivale
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

class Test
{
    int dsa[30],i,j,n,sum,cnt[50],k,rn[30]; //data members
    float av;
public:
    Test()  //default constructor
    {
        i=j=n=0;
        av=sum=k=0;
    }
    void getdata(); //member functions
    void show();
    void avg();
    void Ab_stud();
    void HS_LS();
    void MS_score();
}; //end of class declaration

//Function name: getdata()
//return type: void
//Parameter :Nil
// To accept information of test.

void Test::getdata()
{
    cout<<"\nHow many student in SE Comp Div: A : ";
    cin>>n;
    cout<<"\n\t-----------------------------------------------------";
    cout<<"\n\tEnter the marks scored for first test of subject DSA: ";
    cout<<"\n\t-----------------------------------------------------";
    cout<<"\n\nStudent who remains Absent for the test please enter -1 for them:";
    cout<<"\n                     -------------------------------------         ";
    for(i=0;i<n;i++)
    {
     cout<<"\nEnter the marks of Roll no: "<<i+1<<" : ";
     cin>>dsa[i];
    }
}

void Test::MS_score()
{
    for(i=0;i<50;i++)
    {
        cnt[i]=0;
    }
    for(i=0;i<50;i++)
    {
        for(j=0;j<n;j++)
        {
            if(dsa[j]==i)
            {
                cnt[i]=cnt[i]+1;
            }
        }
    }
    /*cout<<"\n\nCount of marks..\n\n";
    for(i=0;i<50;i++)
    {
        cout<<"\t"<<cnt[i];
    }*/
    cout<<"\n\n Marks Scored by most of the student in test are: \n";
   
    k=0;
    j=0;
        int max=cnt[j];
    for(i=0;i<50;i++)
    {
     if(cnt[i]>=max)
     {
         max=cnt[i];
         k=i;
     }
    }
    cout<<"\n\nMAximum marks "<<k<<" scored by "<<max <<" Students...\n";
    for(i=0;i<n;i++)
    {
        if(dsa[i]==k)
        {
            rn[j]=i;
            j++;
        }
    }
    cout<<"\n\n Students Roll Number are as follows..\n\n";
    for(i=0;i<j;i++)
    {
        cout<<"\t"<<rn[i]+1;
    }
}

void Test::show()
{
    cout<<"\n\nFirst Test Marks of Subject DSA are as follows...\n";
    cout<<"\n*********************************\n";
    cout<<"|  Roll No\t"<<"|"<<" DSA Marks     |";
    cout<<"\n*********************************\n";
    for(i=0;i<n;i++)
    {
        cout<<"|\t"<<i+1<<"\t|\t"<<dsa[i]<<"\t|\n";
    }
    cout<<"---------------------------------\n";
}

void Test::avg()
{
    int p=0;
    cout<<"\nAverage Score of Class = > ";
    for(i=0;i<n;i++)
    {
        if(dsa[i]!=-1)
        {
            sum=sum+dsa[i];
            p++;
        }

    }
    av=sum/p;
    cout<<av;
}

void Test::Ab_stud()
{
    int cnt=0;
    cout<<"\n\nTotal Number of Student Absent for DSA Test\n";
    cout<<"\nRoll No\t Marks\n";
    for(i=0;i<n;i++)
    {
        if(dsa[i]==-1)
        {
            cout<<i+1<<"\tAbsent\n";
            cnt++;
        }
    }
    cout<<"\n\tTotal_Absent_Student :=: "<<cnt;
}

void Test::HS_LS()
{
    int min=0;
    int max=0,rno=0,i=0;
    cout<<"\n\nHighest Score of the Class for DSA Subject are as follows..\n";
    max=dsa[i];
    for(i=0;i<n;i++)
    {
        if(dsa[i]==-1)
        {

        }
        else if(dsa[i]>=max)
        {
            max=dsa[i];
            rno=i;
        }
    }
    cout<<"\n\tDSA Highest Score: "<<"Roll No : "<<rno+1<<" Marks : "<<max;
    cout<<"\n\nLowest Score of the Class for DSA Subject are as follows..\n";
    rno=0;
    min=dsa[j];
    for(j=0;j<n;j++)
    {
        if(dsa[j]==-1)
        {

        }
        else if(dsa[j]<=min)
        {
         min=dsa[j];
         rno=j;
        }
    }
    cout<<"\n\tDSA Lowest Score: "<<"Roll No : "<<rno+1<<" Marks : "<<min;
}

int main()
{
    Test T;
    T.getdata();
    T.show();
    T.avg();
    T.Ab_stud();
    T.HS_LS();
    T.MS_score();
    cout << "\n\n\n!!!Good Bye!!!" << endl; // prints !!!Hello World!!!
    return 0;
}
/***************************************************************************************

[student@localhost Downloads]$ g++ asgn2GRA.cpp
[student@localhost Downloads]$ ./a.out

How many student in SE Comp Div: A : 10

    -----------------------------------------------------
    Enter the marks scored for first test of subject DSA:
    -----------------------------------------------------

Student who remains Absent for the test please enter -1 for them:
                     -------------------------------------        
Enter the marks of Roll no: 1 : 20

Enter the marks of Roll no: 2 : 23

Enter the marks of Roll no: 3 : 25

Enter the marks of Roll no: 4 : -1

Enter the marks of Roll no: 5 : 36

Enter the marks of Roll no: 6 : 40

Enter the marks of Roll no: 7 : 36

Enter the marks of Roll no: 8 : 36

Enter the marks of Roll no: 9 : 36

Enter the marks of Roll no: 10 : 22


First Test Marks of Subject DSA are as follows...

*********************************
|  Roll No    | DSA Marks     |
*********************************
|    1    |    20    |
|    2    |    23    |
|    3    |    25    |
|    4    |    -1    |
|    5    |    36    |
|    6    |    40    |
|    7    |    36    |
|    8    |    36    |
|    9    |    36    |
|    10    |    22    |
---------------------------------

Average Score of Class = > 30

Total Number of Student Absent for DSA Test

Roll No     Marks
4    Absent

    Total_Absent_Student :=: 1

Highest Score of the Class for DSA Subject are as follows..

    DSA Highest Score: Roll No : 6 Marks : 40

Lowest Score of the Class for DSA Subject are as follows..

    DSA Lowest Score: Roll No : 1 Marks : 20

 Marks Scored by most of the student in test are:


MAximum marks 36 scored by 4 Students...


 Students Roll Number are as follows..

    5    7    8    9


!!!Good Bye!!!

***********************************************************************************/

Set Theory implementation using c++

Group A: Assignment no: 01(SPPU Syllabus Assignment no: 01)
Problem Statement:
In Second year Computer Engineering class of M students, set A of students play cricket and set B of students play badminton. Write C/C++ program to find and display-
i.Set of students who play either cricket or badminton or both
ii.Set of students who play both cricket and badminton
iii.Set of students who play only cricket
iv.Set of students who play only badminton
v.Number of students who play neither cricket nor badminton
(Note- While realizing the set duplicate entries are to avoided)

Program Code:

//Assignment No:01 (Group A)
//Author: Nitin Shivale
//Title: Cricket & Badminton
#include <iostream>
using namespace std;
class game
{
    int c,b,m,i,j,k,cnt;
    int setA[10],setB[10],setC[20],setD[20],setAB[20];
    public:
    game()
    {
        c=b=m=0;
        i=j=k=0;
        cnt=0;
    }
    void getdata();
    void show();
    void uni();
    void ninor();
    void common();
    void onlycrick();
    void onlybadminton();
};
void game::getdata()
{
    cout<<"\nHow many students in SE Comp :";
    cin>>m;
    cout<<"\nEnter count of student who plays cricket:";
    cin>>c;
    for(i=0;i<c;i++)
    {
        cout<<"\nEnter the roll no:";
        cin>>setA[i];
    }
    cout<<"\nEnter count of student who plays badminton:";
    cin>>b;
    for(i=0;i<b;i++)
    {
        cout<<"\nEnter the Roll No:";
        cin>>setB[i];
    }
}
void game::uni()
{
    int flag=0;
    for(i=0;i<c;i++)
    {
        setC[k]=setA[i];
        k++;
    }
    for(j=0;j<b;j++)
    {
        for(i=0;i<c;i++)
        {
            if(setB[j]==setA[i])
            {
                flag=1;
            }
        }
        if(flag==0)
        {
            setC[k]=setB[j];
            k++;
        }
        flag=0;
    }
    cout<<"\nThe Student who plays either Cricket or Badminton\n";
    for(i=0;i<k;i++)
    {
        cout<<"\t"<<setC[i];
    }
}

void game::common()
{
    for(i=0;i<c;i++)
    {
     setC[k]=setA[i];
     k++;
    }
    cout<<"\nThe student who plays both...\n";
    for(j=0;j<b;j++)
    {
     for(i=0;i<c;i++)
     {
      if(setB[j]==setA[i])
      {
        cout<<"\t"<<setA[i];
      }
     }
    }
}

void game::ninor()
{
    int z;
    int flag=0;
    for(i=0;i<c;i++)
    {
     setC[k]=setA[i];
     k++;
    }
    for(j=0;j<b;j++)
    {
     for(i=0;i<c;i++)
     {
      if(setB[j]==setA[i])
      {
        flag=1;
      }
     }
     if(flag==0)
     {
      setC[k]=setB[j];
      k++;
     }
     flag=0;
    }

    for(i=0;i<k;i++)
    {
        setD[cnt]=setC[i];
        cnt++;
    }
   cout<<"\n\nThe Student who plays neither Cricket nor Badminton...\n";
   flag=0;
   for(i=1;i<=m;i++)
   {
    for(j=0;j<cnt;j++)
    {
     if(setD[j]==i)
     {
      flag=1;
     }
    }
    if(flag==0)
    {
     setAB[z]=i;
     cout<<"\t"<<i;
     z++;
    }
    flag=0;
   }
}
void game::onlycrick()
{
    int flag=0;
    cout<<"\nThe student only plays Cricket...\n";
    for(i=0;i<c;i++)
    {
        for(j=0;j<b;j++)
        {
            if(setA[i]==setB[j])
            {
                flag=1;
            }
        }
        if(flag==0)
        {
            cout<<"\t"<<setA[i];
        }
        flag=0;
    }
}

void game::onlybadminton()
{
    int flag=0;
    cout<<"\nThe student only plays Badminton...\n";
    for(j=0;j<b;j++)
    {
        for(i=0;i<c;i++)
        {
            if(setB[j]==setA[i])
            {
                flag=1;
            }
        }
        if(flag==0)
        {
            cout<<"\t"<<setB[j];
        }
        flag=0;
    }
}
void game::show()
{
    cout<<"\nThe students who plays Cricket as follows..\n";
    for(i=0;i<c;i++)
    {
        cout<<"\t"<<setA[i];
    }
    cout<<"\nThe students who plays Badminton as follows..\n";
    for(j=0;j<b;j++)
    {
        cout<<"\t"<<setB[j];
    }
}
int main()
{
    game g;
    int ch;
   
     g.getdata();
     g.show();
     g.uni();
     g.ninor();
     g.common();
     g.onlycrick();
     g.onlybadminton();
   

    cout << "\n!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

/*****************************output ********************************************


[student@localhost DSL_LAB_M16_17]$ g++ set.cpp
[student@localhost DSL_LAB_M16_17]$ ./a.out

How many students in SE Comp :15

Enter count of student who plays cricket:5

Enter the roll no:2

Enter the roll no:4

Enter the roll no:6

Enter the roll no:7

Enter the roll no:8

Enter count of student who plays badminton:4

Enter the Roll No:3

Enter the Roll No:4

Enter the Roll No:5

Enter the Roll No:6

The students who plays Cricket as follows..
    2    4    6    7    8
The students who plays Badminton as follows..
    3    4    5    6
The Student who plays either Cricket or Badminton
    2    4    6    7    8    3    5

The Student who plays neither Cricket nor Badminton...
    1    9    10    11    12    13    14    15
The student who plays both...
    4    6
The student only plays Cricket...
    2    7    8
The student only plays Badminton...
    3    5
!!!Hello World!!!
[student@localhost DSL_LAB_M16_17]$



**********************************************************************************/

Monday 29 August 2016

Cinemax Theater implemented using doubly circular linked list

Group B : Assignment No: 02 (SPPU Syllabus Assignment no: 15)
Problem Statement:
The ticket booking system of Cinemax theater has to be implemented using C++ program. There are 10 rows and 7 seats in each row. Doubly circular linked list has to be maintained to keep track of free seats at rows. Assume some random booking to start with. Use array to store pointers (Head pointer) to each row. On demand
a) The list of available seats is to be displayed
b) The seats are to be booked
c) The booking can be cancelled. 
 
Program Code: 
 
 //Cinemax Theoter Asssignment(Group B: 02)
//Author: Mr.Nitin Shivale
#include <iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;

struct node    //Structure for Node i: user information (seat)
{
    int flag;
    char movie_name[20];
    char name[20];
    long mno;
    node *next;
    node *prev;
};

struct hnode  //Header node (stores metadata of each row)
{
    node *next;  //Stores the first address node address of each row.
    int cnt;     //Sotres the number of node(book) in list.
};

class Cinemax   //class name
{
    hnode *head[11]; //array of pointer of type hnode to store ten rows address.
    node *temp,*t1,*p; //data memebers.
    int n,i,j;
   public:
    Cinemax()  //default costructor
    {
     for(i=1;i<=10;i++)
     {
      head[i]=new hnode;   
          head[i]->next= NULL;   //INITIALIZATION OF HEADE ARRAY
      head[i]->cnt=0;
     }
     temp=t1=p=NULL;
     n=i=j=0;        //initialization of all data members.
    }

    void create();
    void show();
    int book_my_show(int,int,char[]);     //Member Functions Declarations.
    int cancel_my_show(int,int,char[]);
}; //end of class definition.


//Function : To book the theoter movie show logic is here..
//No of arguments passed : 03
//1. Row number 2. Number of Tickets 3.Movie name
int Cinemax::book_my_show(int r,int n,char name[20])
{
  cout<<"\nYou request for "<<n <<" Tickets of "<<name<<" movie: \n";
  temp=head[r]->next;
  int max;
  max=head[r]->cnt; //Stores the counter of booked seat.
  if(max==7)
  {
   cout<<"\nSorry there is no seat avialable in this row..";
   return 0;
  }
  else
  {
   int seat[5],cnt=0,sn;
   for(i=0;i<n;i++) //accept the seat number from user to book
   {
    cout<<"\nEnter the seat no's: ";
    cin>>sn;
    seat[i]=sn-1;// store seat number in array.
   }
   i=0;
   while(temp->next!=head[r]->next)//Check upto the last element of list
   {
    if(cnt!=seat[i])
    {
     cnt++;   //if seat no is not equal move forward
     temp=temp->next;
    }
    else
    {
     if(temp->flag==0)//if flag is zero that means seat is not booked.
     {
      strcpy(temp->movie_name,name);
      temp->flag=1;
      cout<<"\nEnter u r name:";  //Store all the user information for that book seat
      cin>>temp->name;
      cout<<"\nEnter u r mobile no: ";
      cin>>temp->mno;
      head[r]->cnt=head[r]->cnt+1; //increment the header counter by one
      cnt=0;  //make the counter zero for next booking of seat
      temp=head[r]->next; //point the temp first node of list for next booking seat.
      i++; //increment the indes of seat array for next seat booking.
      if(i==n)  //if all the seat gets book exit from the loop.
        break;   
     }
    }
   }
 }   
 if((temp->next==head[r]->next)) //Due to the above while condition last node is always out of the logic.
 {
  if(temp->flag==0)              //To store last node booking this code works.
  {
   strcpy(temp->movie_name,name);
   temp->flag=1;
   cout<<"\nEnter u r name:";
   cin>>temp->name;
   cout<<"\nEnter u r mobile no: ";
   cin>>temp->mno;
   head[r]->cnt=head[r]->cnt+1; //increment the header node counter by one.
  }
 }
 return 1; //return value 1 for successful completion of booking.
}


//Function : To cancel the theoter movie show logic is here..
//No of arguments passed : 03
//1. Row number 2. Number of Tickets 3.Movie name

int Cinemax::cancel_my_show(int r,int n,char name[20])
{
  cout<<"\nYour cancel request for "<<n <<" Tickets of "<<name<<" movie: \n";
  temp=head[r]->next;
  int max;
  max=head[r]->cnt; // store the no of nodes booked in row.
  if(max==-1) //check if the list is empty means no booking and still try to cancel.
  {
   cout<<"\nSorry there is no such seat avialable in this row for cancel..";
   return 0; //return 0 for unsuccessful try.
  }
  else
  {
   int seat[5],cnt=0,sn;
   for(i=0;i<n;i++) //Accept seat number from user to cancel the booking.
   {
    cout<<"\nEnter the seat no's: ";
    cin>>sn;
    seat[i]=sn-1; //Store cancel seat number in array seat[].
   }
   i=0;
   while(temp->next!=head[r]->next) //Check upto the last element of list
   {
    if(cnt!=seat[i])
    {
     cnt++;     //if seat number is not matches.
     temp=temp->next; // move to the next seat.
    }
    else
    {
     if(temp->flag==1) //if seat number matches check its flag if it is 1 that means seat is booked.
     {
      strcpy(temp->movie_name,"NIL"); // initialize all its feild to NIL value.
      temp->flag=0;                   // make it's flag 0 means not booked seat is vaccant for booking.
      strcpy(temp->name,"NIL");
      temp->mno=00;
      head[r]->cnt=head[r]->cnt-1;  //Decrement the header count by 1
      cnt=0;   //make the counter zero for next seat number to make it cancel.
      temp=head[r]->next; //point your temp to the first node of list.
      i++;  //increment i for the next seat number to cancel
      if(i==n)  //if all the seat gets cancel exit from the loop.
        break;   
     }
    }
   }
 }   
 if((temp->next==head[r]->next)) //Due to the above while condition last node is always out of the logic.
 {
  if(temp->flag==1)  //check the status of last node if flag is 1 means seat is booked and ready for cancel.
  {
   strcpy(temp->movie_name,"NIL");
   temp->flag=0;                    //make the flag 0 to indicate seat is vaccant.
   strcpy(temp->name,"NIL");
   temp->mno=00;                 //initialize all other value with NIL & ZERO.
   head[r]->cnt=head[r]->cnt-1;  //Decrement the header counter by one.
  }
 }
 return 1; //Return one for successful cancelletion.
}

//Function: To create the Doubly circular linked list for cinemax theoter booking
//no of arguments zero.

void Cinemax::create()
{
    node *f1;
    cout<<"\n\n!!!!!!!!!!!! Welcome To Cinemax Theoter!!!!!!!!!!\n";
    for(i=1;i<=10;i++)
    {
        p = new node;  // Allocate the memory for node
        p->next=NULL;   // initialize all feilds.
        p->prev=NULL;
        p->flag=0;
        strcpy(p->movie_name,"NIL");
        strcpy(p->name,"NIL");
        p->mno=0;

        if(head[i]->next==NULL)//check header next of each row if it null store this node as first node of that row
        {
         head[i]->next= p; //store the address of p in next feild of i th row header node.
         p->prev=p; //initially it's prev and next point to itself i:e p only.
         p->next=p;
        }
        //cout<<"\nAdding the row : "<<i <<" : information\n";

            temp=head[i]->next; // Here onwards we are adding the remaining six node in DCLL.
            f1=temp; //Storing the first node address in this pointer to point to the prev of first node.
            for(j=1;j<=6;j++)//wants to add six node
            {
                t1=new node; // Allocate memeory for node
                t1->flag=0;
                t1->mno=0;   //initialize all it's memory feilds.
                strcpy(t1->movie_name,"NIL");
                strcpy(t1->name,"NIL");
               
                t1->next=head[i]->next; //last node always points to the first node of list in DCLL.
                temp->next=t1; //join the new new node at end of list.
                t1->prev=temp; //new node prev is the previous node address of list.
                f1->prev=t1; //First node always points to the last node of list in DCLL.
                temp=t1; //make the new node (t1) as previous node (temp) for upcoming new node (t1).
            }
            //cout<<"\n Row Number : "<<i<<" : gets created....\n";
     }

}

//Function: To display the whole theoter booking status.
//how any seats are book or how many are vaccant.
//No of arguments zero.
void Cinemax::show()
{
    cout<<"Rows Status are as follows...\n";
    cout<<"\nHead Node\tCol1\t\tCol2\t\tCol3\t\tCol4\t\tCol5\t\tCol6\t\tCol7"; //To display column of the theator.
    for(i=1;i<=10;i++)//Total ten rows and each row seven seats we want to display.
    {
        cout<<"\nRow : "<<i;
        temp=head[i]->next; //Storing the address of i th row in temp to display.
         cout<<"[ "<<head[i]->cnt<<" ]--->"; //show no of nodes booked in the i th row.
        while(temp->next!=head[i]->next) //Travese upto the last node by this condition.
        {
         cout<<"[ "<<temp->flag<<"|"<<temp->movie_name<<"|"<<temp->name<<"]->"; //display flag value, name of movie & name of Ticket holder.
         temp=temp->next; //move towards the next seat.
        }
        if(temp->next==head[i]->next) //Due to the above while condition last node is out of code.
        {
         cout<<"[ "<<temp->flag<<"|"<<temp->movie_name<<"|"<<temp->name<<"]->";//displaying the last node containt.
        }
        cout<<"\n\n";
    }
}

int main()
{
    Cinemax c1; //object of cinemax theoter.
        int row,n,am,ch,amnt=150;
     char mname[20];
    c1.create(); //Function gets call to create the logical view of cinemax theoter.
    do
     {
    cout<< "\n!!!Cinemax Theator!!!" << endl; // prints !!!!!!
   
    cout<<"\n1.Book_my_Show\n2.Display Seat status\n3.Cancel_my_show"; //Show the options to choose.
   
    cout<<"\nEnter u R Choice: ";
    cin>>ch;
    switch(ch)
    {
     case 1:cout<<"\nWelcome To Cinemax Theator For Book your Show...\n";
        cout<<"\n Friday's Movies are as follows...\n";
        cout<<"\n1.Mohenjo_Daro\n2.Rustom\n3.Happy_Bag_Jayegi\n4.Bar_Bar_Dekho\n5.Akira\n6.Rangoon\n7.A Flying_Jatt.\n";
        cout<<"\nEnter u r movie name to book the show:(Note: space is not allowed in movie name)::  ";
                cin>>mname;
        c1.show();
        cout<<"\nEnter the row number to book u r ticket: ";
            cin>>row;
        cout<<"\nHow many Tickets u want to Book: ";
        cin>>n;
        am=c1.book_my_show(row,n,mname);
        if(am!=0)
        {
         c1.show();
         cout<<"\n\n Please pay the cash: u r total amount is: "<<amnt*n;;
         cout<<"\n\nYour booking is confirmed please see the status: ..\n\n";
                }
        else
        {
         cout<<"\n\nTry for another row...\n";
         }
                break;
         case 2:cout<<"\n The Booking status of the Cinemax Theator are as follows...\n\n";
        c1.show();
                break;
         case 3:cout<<"\nWelcome To Cinemax Theator For Cancel your Show...";
        cout<<"\nEnter u r movie name to cancel the show:(Note: space is not allowed in movie name)::  ";
                cin>>mname;
        c1.show();
        cout<<"\nEnter the row number to cancel u r ticket: ";
            cin>>row;
        cout<<"\nHow many Tickets u want to Cancel: ";
        cin>>n;
        am=c1.cancel_my_show(row,n,mname);
        if(am!=0)
        {
         c1.show();
         cout<<"\n\n Your total refund amount is: "<<((amnt*n)-50);;
         cout<<"\n\nYour booking is cancel please see the status: ..\n\n";
                }
        else
        {
         cout<<"\n\nTry for another row...\n";
         }
                break;
    }
     }while(ch!=4);
       
   
    return 0;
}// end of main function


/************************* OUTPUT OF CINEMAX THEATOR *****************************************************************************

[student@localhost Documents]$ g++ cinemax.cpp
cinemax.cpp:14:1: warning: ‘typedef’ was ignored in this declaration [enabled by default]
 };
 ^
cinemax.cpp:20:1: warning: ‘typedef’ was ignored in this declaration [enabled by default]
 };
 ^
[student@localhost Documents]$ ./a.out


!!!!!!!!!!!! Welcome To Cinemax Theoter!!!!!!!!!!

!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 1

Welcome To Cinemax Theator For Book your Show...

 Friday's Movies are as follows...

1.Mohenjo_Daro
2.Rustom
3.Happy_Bag_Jayegi
4.Bar_Bar_Dekho
5.Akira
6.Rangoon
7.A Flying_Jatt.

Enter u r movie name to book the show:(Note: space is not allowed in movie name)::  Akira
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Enter the row number to book u r ticket: 10

How many Tickets u want to Book: 2

You request for 2 Tickets of Akira movie:

Enter the seat no's: 2

Enter the seat no's: 4

Enter u r name:nitin

Enter u r mobile no: 9850562515

Enter u r name:Tejas

Enter u r mobile no: 9923511212
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 2 ]--->[ 0|NIL|NIL]->[ 1|Akira|nitin]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->



 Please pay the cash: u r total amount is: 300

Your booking is confirmed please see the status: ..


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 2

 The Booking status of the Cinemax Theator are as follows...

Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 2 ]--->[ 0|NIL|NIL]->[ 1|Akira|nitin]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 3

Welcome To Cinemax Theator For Cancel your Show...
Enter u r movie name to cancel the show:(Note: space is not allowed in movie name)::  Akira
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 2 ]--->[ 0|NIL|NIL]->[ 1|Akira|nitin]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Enter the row number to cancel u r ticket: 10

How many Tickets u want to Cancel: 1

Your cancel request for 1 Tickets of Akira movie:

Enter the seat no's: 2
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->



 Your total refund amount is: 100

Your booking is cancel please see the status: ..


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 2

 The Booking status of the Cinemax Theator are as follows...

Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 1

Welcome To Cinemax Theator For Book your Show...

 Friday's Movies are as follows...

1.Mohenjo_Daro
2.Rustom
3.Happy_Bag_Jayegi
4.Bar_Bar_Dekho
5.Akira
6.Rangoon
7.A Flying_Jatt.

Enter u r movie name to book the show:(Note: space is not allowed in movie name)::  Rustom
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Enter the row number to book u r ticket: 9

How many Tickets u want to Book: 3

You request for 3 Tickets of Rustom movie:

Enter the seat no's: 1

Enter the seat no's: 3

Enter the seat no's: 7

Enter u r name:Ram

Enter u r mobile no: 9823463223

Enter u r name:Sham

Enter u r mobile no: 8308115014

Enter u r name:Ganesh

Enter u r mobile no: 9923511414
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->



 Please pay the cash: u r total amount is: 450

Your booking is confirmed please see the status: ..


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 2

 The Booking status of the Cinemax Theator are as follows...

Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 1

Welcome To Cinemax Theator For Book your Show...

 Friday's Movies are as follows...

1.Mohenjo_Daro
2.Rustom
3.Happy_Bag_Jayegi
4.Bar_Bar_Dekho
5.Akira
6.Rangoon
7.A Flying_Jatt.

Enter u r movie name to book the show:(Note: space is not allowed in movie name)::  Rangoon
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Enter the row number to book u r ticket: 8

How many Tickets u want to Book: 7

You request for 7 Tickets of Rangoon movie:

Enter the seat no's: 1

Enter the seat no's: 2

Enter the seat no's: 3

Enter the seat no's: 4

Enter the seat no's: 5

Enter the seat no's: 6

Enter the seat no's: 7

Enter u r name:Simran

Enter u r mobile no: 9923511212

Enter u r name:Kaur

Enter u r mobile no: 9923511313

Enter u r name:Amit

Enter u r mobile no: 9850562525

Enter u r name:Shah

Enter u r mobile no: 8308115055

Enter u r name:lalu

Enter u r mobile no: 9923511234

Enter u r name:prasad

Enter u r mobile no: 9923511415

Enter u r name:Narendra

Enter u r mobile no: 9999888812
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 7 ]--->[ 1|Rangoon|Simran]->[ 1|Rangoon|Kaur]->[ 1|Rangoon|Amit]->[ 1|Rangoon|Shah]->[ 1|Rangoon|lalu]->[ 1|Rangoon|prasad]->[ 1|Rangoon|Narendra]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->



 Please pay the cash: u r total amount is: 1050

Your booking is confirmed please see the status: ..


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 1

Welcome To Cinemax Theator For Book your Show...

 Friday's Movies are as follows...

1.Mohenjo_Daro
2.Rustom
3.Happy_Bag_Jayegi
4.Bar_Bar_Dekho
5.Akira
6.Rangoon
7.A Flying_Jatt.

Enter u r movie name to book the show:(Note: space is not allowed in movie name)::  Akira
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 7 ]--->[ 1|Rangoon|Simran]->[ 1|Rangoon|Kaur]->[ 1|Rangoon|Amit]->[ 1|Rangoon|Shah]->[ 1|Rangoon|lalu]->[ 1|Rangoon|prasad]->[ 1|Rangoon|Narendra]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Enter the row number to book u r ticket: 8

How many Tickets u want to Book: 2

You request for 2 Tickets of Akira movie:

Sorry there is no seat avialable in this row..

Try for another row...

!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 3

Welcome To Cinemax Theator For Cancel your Show...
Enter u r movie name to cancel the show:(Note: space is not allowed in movie name)::  Rangoon
Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 7 ]--->[ 1|Rangoon|Simran]->[ 1|Rangoon|Kaur]->[ 1|Rangoon|Amit]->[ 1|Rangoon|Shah]->[ 1|Rangoon|lalu]->[ 1|Rangoon|prasad]->[ 1|Rangoon|Narendra]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Enter the row number to cancel u r ticket: 8

How many Tickets u want to Cancel: 1

Your cancel request for 1 Tickets of Akira movie:

Enter the seat no's: 7

Rows Status are as follows...

Head Node    Col1        Col2        Col3        Col4        Col5        Col6        Col7
Row : 1[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 2[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 3[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 4[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 5[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 6[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 7[ 0 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->


Row : 8[ 7 ]--->[ 1|Rangoon|Simran]->[ 1|Rangoon|Kaur]->[ 1|Rangoon|Amit]->[ 1|Rangoon|Shah]->[ 1|Rangoon|lalu]->[ 1|Rangoon|prasad]->[ 0|NIL|NIL]->


Row : 9[ 3 ]--->[ 1|Rustom|Ram]->[ 0|NIL|NIL]->[ 1|Rustom|Sham]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Rustom|Ganesh]->


Row : 10[ 1 ]--->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 1|Akira|Tejas]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->[ 0|NIL|NIL]->

Your total refund amount is: 100

Your booking is cancel please see the status: .


!!!Cinemax Theator!!!

1.Book_my_Show
2.Display Seat status
3.Cancel_my_show
Enter u R Choice: 4



**********************************************************************************************************************************/

Doubly linked list implementation

Group B:(Assignment No: 03)(SPPU Syllabus Assignment No : 20)
Problem Statement: Let x = (x1,x2, ... , xn) and y = (y1, y2,.... , ym) be two doubly linked lists. Assume that in each linked list, the nodes are in non-decreasing order of  their data-field values. Write C/C++ program to merge the two lists to obtain a new linked list z in which the nodes are also in this order. Following the merge, x and y should represent empty lists because each node initially in x or y is now in z. No additional nodes may be used.
 
Program Code :
 
 //============================================================================
// Name        : Dll_Merge.cpp
// Author      : Nitin Shivale
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
// Structure to define node for dynamic mem allocation
struct node
{
    int data;
    node *prev,*next; // dll that's why two pointer.
};

// Structure for header node to store the metadata.
struct hnode
{
    int cnt;
    node *next; // next pointer to store the add of first node in list.
};

// define a  class  dll for various operations.
class dll
{
    hnode *head;    //data memebers.
    node *temp,*p;
public:
    dll()  //Default Constructor
    {
        head=NULL;
        temp=p=NULL;
    }
    //Member Functions...
    hnode *create(); //returns the head node address and create DLL.
    void show(hnode *); //To display DLL.
    hnode *merge_dll(hnode *,hnode *);//To merge both the List in Ascending order.

};//end of class dll


hnode * dll::create()
{
 int n;
 cout<<"\nHow many node u want to insert in DLL: ";
 cin>>n;
 if(n==0)
 {
  head=new hnode;
  head->next=NULL;
  head->cnt=0;
  return head;
 }
 while(n>0)
 {
     p= new node; //Allocation of memory for node
     cout<<"\nEnter Data of node: ";
     cin>>p->data;
     p->next=NULL;//initialization of node p
     p->prev=NULL;
     if(head==NULL) //Check for head node if null create header node.
     {
         head=new hnode; //Allocate dynamic mem for head node.
         head->next=p; //store the add of first node in head next.
         head->cnt=1; // increment the counter of header feild.
     }
     else
     {
         temp=head->next; //temp points the first node of list
         while(temp->next!=NULL)
         {
             temp=temp->next;  //go upto the next null.
         }
         temp->next=p; // at the end attache the node
         p->prev=temp;  // previous of p is temp
         head->cnt=head->cnt+1; // increment the counter.
     }
     n=n-1; // decrement the cnt of number of nodes.
 }
    return head; // The function returns the head node address.
}

void dll::show(hnode *h1)
{
    temp=h1->next; //temp points to the first node of list.
    cout<<"\n|cnt : "<<h1->cnt<<"|"<<h1->next<<"|-->";  //Display the containt of header node.
    while(temp!=NULL)
    {
        //the following cout display the prev pointer value, next pointer value and data value of node.
        cout<<"|"<<temp->prev<<"|Data is:"<<temp->data<<" |"<<temp->next<<"|<->"; //Display whole list information.
        temp=temp->next;// To traverse to the next node.
    }
        cout<<"\n";
}

//To merge this both the list in ascending order.

hnode * dll::merge_dll(hnode *h1,hnode *h2)
{
  node *p,*t1,*t2; //temporary pointer variables. t1 points to first list i:e h1 and t2 points to second list i:e h2.
  t1=h1->next;
  cout<<"\nt1 is...>"<<t1;
  t2=h2->next;
  cout<<"\nt2 is...>"<<t2;
  hnode *h3; //creating the third header node which stores the address of merge list i:e resultant list.
  h3=new hnode;   
  h3->cnt=0;  //init of header node 3
  h3->next=NULL;
  if(h1->next==NULL) //check if first list is empty
  {
   h3->next=h2->next; //assign address of second list to h3
   h3->cnt=h2->cnt; //store no of node in h2
   h2->next=NULL;  //make the second list i:e h2 null
   return h3;  //return h3 as final list
  }
  if(h2->next==NULL) //check if second list is empty
  {
   h3->next=h1->next; //assign address of first list i:e h1 to h3.
   h3->cnt=h1->cnt; //also store no of nodes in h1 to h3
   h1->next=NULL; //make the h1 i:e first list empty.
   return h3;  //return h3 as a final list.
  }
  if(t1->data<t2->data) //now if both are not null then check which list data is less if t1 nodes data is less than t2 node
  {
   h3->next=t1; //store t1 node as a first node of h3
   h3->cnt=1; //make the h3 cnt one.
   p=h3->next; //point temporary pointer variable p to first node of h3.
   t1=t1->next; //move to the next node
  }
  else  //if t2 node data is less than t1 node then
  {
   h3->next=t2; //store t2 node as a first node of h3
   h3->cnt=1; //make the h3 cnt one
   p=h3->next; //point temporary pointer variable p to first node of h3.
   t2=t2->next;//move to the next node
  }
  while(t1!=NULL&&t2!=NULL) //do the following till you are not getting the both lists end is null.(both condition must be true)
  {
   if(t1->data<t2->data)//check if t1 data is less than t2 data if yes do the following
   {
    p->next=t1; //connect t1 with the previous node i:e p (p stores the address of previous node)
    t1->prev=p; //connect t1 previous with p
    t1=t1->next; // go to the next node for checking.
    h3->cnt=h3->cnt+1; //increment the counter of h3 i:e metadata.
    p=p->next; //also move the temporary pointer p to the next node after sucessful connection to acts as prevoius node for the next node to connect
   }
   else //check if t2 data is less than t1 data then do the following
   {
    p->next=t2; //connect t2 with the previous node i:e p (p stores the address of previous node)
    t2->prev=p; //connect t2 previous with p
    t2=t2->next; // go to the next node for checking.
    h3->cnt=h3->cnt+1; //increment the counter of h3 i:e metadata.
    p=p->next;//also move the temporary pointer p to the next node after sucessful connection to acts as prevoius node for the next node to connect.
   }
  }//end of while loop.
  if(t1!=NULL)//connect all the remaining nodes of t1 to h3 till t1 is not null
  {
   p->next=t1;
   t1->prev=p;
   h3->cnt=h3->cnt+1;
  }
  if(t2!=NULL)//connect all the remaining nodes of t2 to h3 till t2 is not null
  {
   p->next=t2;
   t2->prev=p;
   h3->cnt=h3->cnt+1;
  }
  h1->next=h2->next=NULL; //make the first list(h1) and second list(h2) next NULL bcaz all the node of both list get merged with third list h3.
 return h3; //return final list address h3.
}
//Program execution starts from main function.
int main()
{
    dll d1,d2,d3; //objects of class dll gets created.
    hnode *hd1,*hd2,*hd3; //pointer variables of hnode required to store address of lists.
    hd1=hd2=NULL; //initially they are null
    cout<<"\nFirst DLL :";
    hd1=d1.create(); //after calling of create function, address of first list gets stored into hd1.
    d1.show(hd1); //passing the address of first list hd1 to show function to display the whole list.
    cout<<"\n\nSecond DLL :";
    hd2=d2.create();//after calling of create function, address of second list gets stored into hd2.
    d2.show(hd2);//passing the address of second list hd2 to show function to display the whole list.
    cout<<"\n\nAfter Merge the DLL as Follows...\n";
    hd3=d3.merge_dll(hd1,hd2); //passing the addresses of both the list to merge function to merge both list in ascending order and store merge
                                    // address in hd3.
    d3.show(hd3); //passing the address of Merge list hd3 to show function to display the whole Merge list.

    return 0;
}
/**************************************ouput*****************************************

[student@localhost Documents]$ g++ dll_mrg.cpp
[student@localhost Documents]$ ./a.out

First DLL :
How many node u want to insert in DLL: 3

Enter Data of node: 5

Enter Data of node: 15

Enter Data of node: 18

|cnt : 3|0x89a010|-->|0|Data is:5 |0x89a050|<->|0x89a010|Data is:15 |0x89a070|<->|0x89a050|Data is:18 |0|<->

Second DLL :
How many node u want to insert in DLL: 3

Enter Data of node: 10

Enter Data of node: 20

Enter Data of node: 30

|cnt : 3|0x89a090|-->|0|Data is:10 |0x89a0d0|<->|0x89a090|Data is:20 |0x89a0f0|<->|0x89a0d0|Data is:30 |0|<->

After Merge the DLL as Follows...

t1 is...>0x89a010
t2 is...>0x89a090

|cnt : 6|0x89a010|-->|0|Data is:5 |0x89a090|<->|0x89a010|Data is:10 |0x89a050|<->|0x89a090|Data is:15 |0x89a070|<->|0x89a050|Data is:18 |0x89a0d0|<->|0x89a070|Data is:20 |0x89a0f0|<->|0x89a0d0|Data is:30 |0|<->

**************************************************************************************/