sign up I login
 advanced
refer a friend - earn nickels!!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: C++......
Forum Index -> Games, Puzzles and Quizzes like the article? email it to a friend.  
Author Message
antonyajay21 (511)

Blazing goIITian

Olaaa!! Perrrfect answer. 93  [116 rates]

antonyajay21's Avatar

total posts: 339    
online Online
Can upoint out the error please...

Be not afraid of growing slowly.
Be afraid only of standing still.

 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
Aatish (2308)

Blazing goIITian

Olaaa!! Perrrfect answer. 414  [533 rates]

Aatish's Avatar

total posts: 1102    
offline Offline
first it must ask the size of both the matrices and then compare the two sizes.........

If they are equal then only do the sum otherwise say matrices cannot be added.........

............................................................................................................................................................................................
There's Light at the end of every Tunnel, so KEEP MOVING....
Best of luck to all my mates....
............................................................................................................................................................................................
 this reply: 2 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
antonyajay21 (511)

Blazing goIITian

Olaaa!! Perrrfect answer. 93  [116 rates]

antonyajay21's Avatar

total posts: 339    
online Online
/* A program to sort a range of numbers with Insertion
   and Quicksort, check their sorting time and prompt
   the result on the screen */


/* use header file*/
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include <values.h>
#include <time.h>
#include <string.h>
#include <conio.h>

/* define variable */
const int max=29000;
int list[max];
FILE *fp;
clock_t start,end;
char any1[8];

/* Insertion sort module */
void insertion(int min1,int max1)
{
    int a,b,v;

    for(a=min1;a<=max1;a++)
    {
       v = list[a];
       b = a;
       do
       {
       list[b] = list[b-1];
       b = b - 1;
       }  while(list[b-1] > v);
       list[b] = v;
    }
}

/* sort partitioning element */
void sorthree(int x,int y,int z)
{
int temp;

if (list[x] > list[y])
{
   temp = list[x];
   list[x] = list[y];
   list[y] = temp;
}
if (list[z] < list[x])
{
   temp = list[x];
   list[x] = list[z];
   list[z] = temp;
   temp = list[y];
   list[y] = list[z];
   list[z] = temp;
}
if ((list[z] > list[x]) && (list[z] < list[y]))
{
   temp = list[y];
   list[y] = list[z];
   list[z] = temp;
}
}

/* Quicksort module */
void quicksort(int min2,int max2)
{
int m,v,t,i,j,q;

if ((max2-min2) > 9)
{
   m = (max2-min2+1)/2;
   sorthree(min2,m,max2);
   max2=max2-1;
   q = list[m];
   list[m] = list[max2];
   list[max2] = q;

   v = list[max2];
   i = min2+1;
   j = max2-1;
   do
   {
      do
      {
     i=i+1;
      } while (list[i] < v);
      do
      {
     j=j-1;
      } while (list[j] > v);
      t = list[i];
      list[i] = list[j];
      list[j] = t;
   }  while (i<j);
   list[j]=list[i];
   list[i]=list[max2];
   list[max2]=t;
   quicksort(min2,i-1);
   quicksort(i+1,max2);
 }
else
 insertion(m,max2);
}


/* main program */
void main()
{
int i,j,k,min,max1;
char any2[8];

clrscr();
cout << "Enter a file name to store data :";
cin >> any1;                                  /* input data file name on */
cout << '\n' << "Generating file...waits\n\n";/*   screen */

fp = fopen(any1,"w");
    for(j=0;j<max/200;j++)
    {
       for(i=0;i<200;i++)    /* write random values to file */
       {
       k = rand();
       fprintf(fp,"%d\n",k);
       }
    }
fclose(fp);

fp = fopen(any1,"r");
    i = 0;
    while(fscanf(fp,"%d\n",&k) != EOF)
    {
      list[i] = k;  /* read values from file and assign to an array */
      i = i + 1;
    }
fclose(fp);
min = 0;
max1 = max;
max1=max1-1;
cout << "Sorting with Quicksort... waits" << '\n';
start = clock();
quicksort(min,max1);   /* sort an unsorted list with quicksort */
end=clock();
float result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
     << " numbers in Quciksort is : " << result << " second(s)" << "\n\n";


cout << "Enter an output file for Quicksort : ";
cin >> any2;

fp = fopen(any2,"w");
  for(i=0;i<max;i++)
  {                   /* write the output from quicksort and put them */
      k = list[i];    /*to a file */
      fprintf(fp,"%d\n",k);
  }
fclose(fp);

fp = fopen(any1,"r");
    i = 0;
    while(fscanf(fp,"%d\n",&k) != EOF)
    {
      list[i] = k;
      i = i + 1;
    }
fclose(fp);
cout << "\nSorting with Insertion Sort... waits" << '\n';
start = clock();
insertion(0,max);   /* sort an unsorted list with insertion sort */
end=clock();
result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
     << " numbers in Insertion is : " << result << " second(s)" << "\n\n";

cout << "Sort an already sorted array again with Quicksort..." << '\n';
min = 0;
max1 = max;
max1=max1-1;
start = clock();
quicksort(min,max1);  /* sort an already sort list with quicksort */
end=clock();
result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
     << " numbers in Quicksort is : " << result << " second(s)" << "\n";

cout << "Sort an already sorted array again with Insertion sort..." << '\n';
start = clock();
insertion(0,max);   /* sort an already list with insertion sort */
end=clock();
result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
     << " numbers in Insertion sort is : " << result << " second(s)" << '\n';
}




Be not afraid of growing slowly.
Be afraid only of standing still.

 this reply: 10 points  (with Olaaa!! Perrrfect answer.   in 2 votes )   [?]
 
You have to be logged on to rate
  
antonyajay21 (511)

Blazing goIITian

Olaaa!! Perrrfect answer. 93  [116 rates]

antonyajay21's Avatar

total posts: 339    
online Online
# include<iostream.h>
# include<conio.h>
# include<stdio.h>
#include <string.h>
#include <process.h>

int n;
class atp
      {
         int age,rank,title,sal;
         char name[10];

         public:

             void getdata();
             void putdata();
             void sort();
             void up_earning(int a)
             {
                sal=a;
             }
             void up_rank(int b)
             {
                rank=b;
             }
             char* nm()
             {
                return name;
             }

      }b[10],temp;

     void atp :: getdata()
     {
         cout<<"\n Enter the name : ";
         gets(name);
         cout<<"\n Enter the age : ";
         cin>>age;
         cout<<"\n Enter the rank : ";
         cin>>rank;
         cout<<"\n Enter the number of titles won : ";
         cin>>title;
         cout<<"\n Enter the salary : ";
         cin>>sal;

    }

    void atp :: putdata()
     {
         cout<<"\n\n";
         cout<<
         name;
         cout<<"  \t ";
         cout<<age;
         cout<<"    \t ";
         cout<<rank;
         cout<<"  \t ";
         cout<<title;
         cout<<"      \t ";
         cout<<sal;
         cout<<"\n";
    }

    void atp :: sort()
    {
       int val;
       for(int i=0;i<n;i++)
       {
         for(int j=0;j<n-1-i ;j++)
         {
            val=strcmp(b[i].name,b[i+1].name) ;
            if(val>0)
            {
                   temp=b[j];
                   b[j]=b[j+1];
                   b[j+1]=temp;
            }
         }
      }
    }
     void exit()
     {
       exit(0);
     }

     void main()
{
    clrscr();
    char ch1;
    char ch;
    cout<<"*********************************WELCOME*************************************";

    cout<<"\n Enter the number of items : ";
    cin>>n;
    cout<<"\n INPUT DATA \n";
    for(int i=0;i<n;i++)
    {
       b[i].getdata();
       cout<<"\n";
    }

    do
      {
        do
         {

            int  choice;
            cout<<"\n\nMENU\n\n";
            cout<<"\n1) UPDATE EARNINGS\n";
            cout<<"\n2) UPDATE RANK \n";
            cout<<"\n3) SORT \n";
            cout<<"\n4) DISPLAY RECORD \n";
            cout<<"\n5) EXIT \n";
            cout<<"\n\nEnter your choice :";
            cin>>choice;
            if(choice==1)
            {
                int r;
                char atp_name[10];
                cout<<"Enter the name of the player whose salary has to be updated : \n";
                gets(atp_name);
                for(int i=0;i<n;i++)
                {
                    if ((strcmp(atp_name,b[i].nm()))==0)
                    {
                       cout<<"Enter the new salary : \n";
                       cin>>r;
                       b[i].up_earning(r);
                     }
                }
            }
            if(choice==2)
            {
                   int s;
                    char atp_name[10];
                    cout<<"Enter the name of the player whose salary has to be updated : \n";
                    gets(atp_name);
                    for(int i=0;i<n;i++)
                    {
                        if ((strcmp(atp_name,b[i].nm()))==0)
                        {
                            cout<<"Enter the new rank : \n";
                            cin>>s;
                            b[i].up_rank(s);
                        }
                    }
            }

            if(choice==3)
            {
                b[i].sort();
            }

            if(choice==4)
            {
            cout<<"NAME \t AGE \t  RANK \t TITLES WON \t SALARY";
                for(int i=0;i<n;i++)
                {
                    b[i].putdata();
                }
            }

            if(choice==5)
            exit();
            if((choice!=1)&&(choice!=2)&&(choice!=3)&&(choice!=4)&&(choice!=5))
            cout<<"\n\nWRONG CHOICE\n\n";
            cout<<"\n\nDo you want to go back to the menu?\n\n";
            cin>>ch1;

          } while(ch1=='y');

        cout<<"\n\nDo You Want to continue :";
        cin>>ch;
        getch();
       }
       while(ch=='y');
}

OUTPUT

*********************************WELCOME*************************************
 Enter the number of items : 2

 INPUT DATA

 Enter the name : RAPHAEL

 Enter the age : 18

 Enter the rank : 1

 Enter the number of titles won : 50

 Enter the salary : 5000


 Enter the name : AVINASH

 Enter the age : 17

 Enter the rank : 10

 Enter the number of titles won : 20

 Enter the salary : 2000





INPUT DATA

 Enter the name : RAPHAEL

 Enter the age : 18

 Enter the rank : 1

 Enter the number of titles won : 50

 Enter the salary : 5000


 Enter the name : AVINASH

 Enter the age : 17

 Enter the rank : 10

 Enter the number of titles won : 20

 Enter the salary : 2000



MENU


1) UPDATE EARNINGS

2) UPDATE RANK

3) SORT

4) DISPLAY RECORD

5) EXIT


Enter your choice :1
Enter the name of the player whose salary has to be updated :
AVINASH
Enter the new salary :
3000


Do you want to go back to the menu?


Be not afraid of growing slowly.
Be afraid only of standing still.

 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
antonyajay21 (511)

Blazing goIITian

Olaaa!! Perrrfect answer. 93  [116 rates]

antonyajay21's Avatar

total posts: 339    
online Online
The program is designed in such a way that the programer uses only a particular format.We did this progam long before.That time we wern't cosidered abt robustness

Be not afraid of growing slowly.
Be afraid only of standing still.

 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
Aatish (2308)

Blazing goIITian

Olaaa!! Perrrfect answer. 414  [533 rates]

Aatish's Avatar

total posts: 1102    
offline Offline
This is the PROJECT what I submitted to the BOARDS.......SELF-MADE.........

ENJOY!!!!!!!!!!!!!


#include <conio.h>
#include <dos.h>
#include <string.h>
#include <fstream.h>
#include <process.h>
#include <stdlib.h>
#include <stdio.h>

   int check=1;    // DECLARED A GLOBAL VARIABLE..
   void pass();
   void admin();
   void start();
   void day();
   void new_entry();
   void deletion();
    class train
    {
    private:

    char train_name[50],from[50],to[50];
    int ar_h,ar_m;
    int train_num;
    public :
    int getno()
    {
    return train_num;
    }
    void entry()
    {
    clrscr();
    cout<<"\n\tEnter the details of the Train : ";
    cout<<"\n\n\t\tEnter the TRAIN NO.      : ";
    cin>>train_num;
    cout<<"\n\n\t\tEnter the TRAIN NAME     : ";
    gets(train_name);
    cout<<"\n\n\t\tEnter the ROUTE... ";
    cout<<"\n\n\t\tFROM   : ";
    gets(from);
    cout<<"\n\t\tTO     : ";
    gets(to);
    cout<<"\n\n\t\tEnter Arrival Time   : ";
    cout<<"\n\n\t\tHours : ";
    cin>>ar_h;
    cout<<"\n\t\tMins  : ";
    cin>>ar_m;
    }
    void display(int q)
    {
    gotoxy(8,q);
        cout<<train_num;
    gotoxy(20,q);
        cout<<train_name;
    gotoxy(39,q);
        cout<<from;
    gotoxy(55,q);
        cout<<to;
    gotoxy(69,q);
        cout<<ar_h<<":"<<ar_m;
    }
    };

class lines
{
public :
        void line_hor(int, int, int, char ) ;
        void line_ver (int, int, int, char) ;

} ;

        void lines::line_hor(int column1, int column2, int row, char c)
        {
           for( ;column1 <= column2 ; column1++ )
           {
            gotoxy(column1,row) ;
            cout<<c ;
           }
        }
        void lines :: line_ver(int row1, int row2, int column, char c)
        {
           for ( ; row1<=row2; row1++ )
           {
              gotoxy(column,row1) ;
              cout <<c ;
           }
        }


class menu
{
public :
        char main_menu() ;
} ;




char menu :: main_menu()
{
   lines line ;
   clrscr() ;

   textbackground(BLUE);
   textcolor(WHITE) ;
   clrscr();

   if(check==1)
   {
   line.line_hor(1,80,3,223);
   line.line_hor(1,80,47,223);
   line.line_ver(1,50,4,219);
   line.line_ver(1,50,77,219);

   gotoxy(27,10);
   cout<<"ST. THOMAS SR. SEC. SCHOOL";
   gotoxy(28,20);
   cout<<"Computer Science Project";
   gotoxy(31,25) ;
   cout <<"RAILWAY - HELPLINE" ;
   gotoxy(45,42);
   cout<<"MADE BY :";
   gotoxy(55,42);
   cout<<"Aatish Pandit";
   gotoxy(55,43);
   cout<<"Nitant Singh Chouhan";
   gotoxy(55,44);
   cout<<"Franklin D. Xavier";

   check++;
   getch() ;
   }

   clrscr();

   line.line_hor(1,80,3,223);
   line.line_hor(1,80,47,223);
   line.line_ver(1,50,4,219);
   line.line_ver(1,50,77,219);

    textcolor(YELLOW+BLINK) ;
    gotoxy(25,5) ;
    cprintf("WELCOME TO MANDSAUR RAILWAY STATION") ;
    gotoxy(29,8);
    cprintf("This is The Railway-Helpline");
    gotoxy(10,17) ;
    cout <<"Enter Your Choice accordingly:" ;
    gotoxy(13,22) ;
    cout <<"Press 1 for Today's Time Table..." ;
    gotoxy(13,24) ;
    cout <<"Press 2 for Particular DAY..." ;
    gotoxy(13,26) ;
    cout <<"Press 'e' to exit...." ;
    gotoxy(60,45) ;
    cout <<"**ADMIN press 0**" ;
    char ch = getch();
    return (ch);
}


void draw_table()
{
textcolor(WHITE);
clrscr();
lines line;
    line.line_hor(3,78,8,219);
    line.line_hor(3,78,42,219);
    line.line_ver(8,42,2,219);
    line.line_ver(8,42,79,219);
    line.line_ver(8,42,14,219);
    line.line_ver(8,42,33,219);
    line.line_ver(8,42,48,219);
    line.line_ver(8,42,63,219);
    line.line_hor(3,78,12,219);
gotoxy(4,10);
    cout<<"TRAIN NO.";
gotoxy(19,10);
    cout<<"TRAIN NAME";
gotoxy(39,10);
    cout<<"FROM";
gotoxy(55,10);
    cout<<"TO";
gotoxy(66,10);
    cout<<"ARRIVAL TIME";

}
void weekday(int chek)
{
label2:

int flag = 1;
char v='y';

    if(chek == 1)          //condition for insertion.....
    {
        fstream m("weekday.txt", ios::out | ios::app);
        train t;
        char w ;

        clrscr();
          lines line;
           line.line_hor(1,80,3,223);
           line.line_hor(1,80,47,223);
           line.line_ver(1,50,4,219);
           line.line_ver(1,50,77,219);

        gotoxy(20,15);
        cout<<"Want to make new entry ? ";
        cin>>w;
        while( w=='y'|| w=='Y' )
        {
        clrscr();
        t.entry();
        m.write( (char*)&t , sizeof(t) );

             if( ! m.fail() )
            cout<<"\n\n\tRecord added succesfully";

        cout<<"\n\n\tWant to enter more ? ";
        cin>>w;
        }
        m.close();
    }                     //end of 'if' for insertion....

    delete_again :

    char ch = 'y';
    if(chek==-1)
    {
        clrscr();
           lines line;
               line.line_hor(1,80,3,223);
               line.line_hor(1,80,47,223);
               line.line_ver(1,50,4,219);
               line.line_ver(1,50,77,219);

    gotoxy(20,20);
    cout<<"Want to display ? ";
    cin>>v;
    }
        if( v =='y' || v =='Y' )
        {
        train u;
        fstream m("weekday.txt",ios::in);
        int x=16;
        m.seekg(0,ios::beg);
        draw_table();
        gotoxy(28,5);
        cout<<"Weekday's Time Table";

            while( !m.eof() )
            {
                m.read((char*)&u , sizeof(u));
                  if( !m.eof() )
                  {
                    u.display(x);
                    x+=3;
                  }
            }
        m.close();
        }
        if( chek==1 || chek != -1 )
        {
            int i=44;
            if ( chek == 1 )
            {
                gotoxy(20,i++);
                cout<<"Press 'a' to return back to ADMIN menu...";
            }
            gotoxy(20,i++);
            cout<<"Press 'r' to return back to MAIN menu...";

            if ( chek != 1 )
            {
                gotoxy(20,i++);
                cout<<"Press 'b' to return to PREVIOUS menu...";
            }
            gotoxy(20,i++);
            cout<<"Press 'e' to exit....";

            again6:

            char z ;
            z = getch();

            if( z=='a' && chek == 1)
               admin();
            else if(z=='r')
               start();
            else if(z=='b' && chek != 1)
               day();
            else if(z=='e')
               exit(-1);
            else
               goto again6;
        }

    else if(chek == -1 )
    {
        train t;
        fstream g("temp1.txt",ios::out);
        fstream m("weekday.txt",ios::in);
        m.seekg(0, ios::beg);
        char c;
        int tn;

        gotoxy(20,44);clreol();
        cout<<"Enter The Train No. you want to delete...";
        cin>>tn;

            while ( !m.eof() )
            {
                 m.read ( (char*)&t , sizeof(t) );
                 if( !m.eof() )
                 {
                 if ( tn != t.getno() )
                 {
                    g.write((char *)& t,sizeof(t));
                 }
                 else
                 {
                     flag = 0;
                     gotoxy(30,46);
                     cout<<"Record deleted...";
                 }
                 }

            }
            m.close();
            g.close();
        remove("weekday.txt");
        rename("temp1.txt", "weekday.txt");

            if(flag == 1)
            {
                 gotoxy(30,46);
                 cout<<"Record not found!!!";
            }
        gotoxy(26,48);
        cout<<"Do you want to delete more  (y/n)....";
        cin>>ch;

            if(ch == 'y' || ch=='Y')
            {
            goto delete_again;
            }
            else
            {
            goto dontdelete;
            }
    }


    dontdelete :
            clrscr();
            lines line;
               line.line_hor(1,80,3,223);
               line.line_hor(1,80,47,223);
               line.line_ver(1,50,4,219);
               line.line_ver(1,50,77,219);
    int j = 18;

    if( chek==1 || chek==-1 )
    {
        gotoxy(20,j+=2);
        cout<<"Press 'a' to return back to ADMIN menu...";
    }
    gotoxy(20,j+=2);
    cout<<"Press 'r' to return back to MAIN menu...";
    if( chek!=1 && chek!=-1 )
    {
        gotoxy(20,j+=2);
        cout<<"Press 'b' to return to PREVIOUS menu...";
    }
    gotoxy(20,j+=2);
    cout<<"Press 'e' to exit....";

    again5:

    char z ;
    z = getch();

    if(z=='a'&& ( chek==1 || chek==-1 ) )
       admin();
    else if(z=='r')
       start();
    else if(z== 'b' && ( chek!=1 && chek!=-1 ) )
       day();
    else if(z=='e')
       exit(-1);
    else
       goto again5;
}

void weekend(int chek)
{
label2:

int flag = 1;
char v='y';

    if(chek == 1)          //condition for insertion.....
    {
        fstream m("weekend.txt", ios::out | ios::app);
        train t;
        char w ;

        clrscr();
          lines line;
           line.line_hor(1,80,3,223);
           line.line_hor(1,80,47,223);
           line.line_ver(1,50,4,219);
           line.line_ver(1,50,77,219);

        gotoxy(20,15);
        cout<<"Want to make new entry ? ";
        cin>>w;
        while( w=='y'|| w=='Y' )
        {
        clrscr();
        t.entry();
        m.write( (char*)&t , sizeof(t) );

             if( ! m.fail() )
            cout<<"\n\n\tRecord added succesfully";

        cout<<"\n\n\tWant to enter more ? ";
        cin>>w;
        }
        m.close();
    }                     //end of 'if' for insertion....

    delete_again :

    char ch = 'y';
    if(chek==-1)
    {
        clrscr();
           lines line;
               line.line_hor(1,80,3,223);
               line.line_hor(1,80,47,223);
               line.line_ver(1,50,4,219);
               line.line_ver(1,50,77,219);

    gotoxy(20,20);
    cout<<"Want to display ? ";
    cin>>v;
    }
        if( v =='y' || v =='Y' )
        {
        train u;
        fstream m("weekend.txt",ios::in);
        int x=16;
        m.seekg(0,ios::beg);
        draw_table();
        gotoxy(28,5);
        cout<<"Weekend's Time Table";

            while( !m.eof() )
            {
                m.read((char*)&u , sizeof(u));
                  if( !m.eof() )
                  {
                    u.display(x);
                    x+=3;
                  }
            }
        m.close();
        }
        if( chek==1 || chek != -1 )
        {
            int i=44;
            if ( chek == 1 )
            {
                gotoxy(20,i++);
                cout<<"Press 'a' to return back to ADMIN menu...";
            }
            gotoxy(20,i++);
            cout<<"Press 'r' to return back to MAIN menu...";

            if ( chek != 1 )
            {
                gotoxy(20,i++);
                cout<<"Press 'b' to return to PREVIOUS menu...";
            }
            gotoxy(20,i++);
            cout<<"Press 'e' to exit....";

            again6:

            char z ;
            z = getch();

            if( z=='a' && chek == 1)
               admin();
            else if(z=='r')
               start();
            else if(z=='b' && chek != 1)
               day();
            else if(z=='e')
               exit(-1);
            else
               goto again6;
        }

    else if(chek == -1 )
    {
        train t;
        fstream g("temp1.txt",ios::out);
        fstream m("weekend.txt",ios::in);
        m.seekg(0, ios::beg);
        char c;
        int tn;

        gotoxy(20,44);clreol();
        cout<<"Enter The Train No. you want to delete...";
        cin>>tn;

            while ( !m.eof() )
            {
                 m.read ( (char*)&t , sizeof(t) );
                 if( !m.eof() )
                 {
                 if ( tn != t.getno() )
                 {
                    g.write((char *)& t,sizeof(t));
                 }
                 else
                 {
                     flag = 0;
                     gotoxy(30,46);
                     cout<<"Record deleted...";
                 }
                 }

            }
            m.close();
            g.close();
        remove("weekend.txt");
        rename("temp1.txt", "weekend.txt");

            if(flag == 1)
            {
                 gotoxy(30,46);
                 cout<<"Record not found!!!";
            }
        gotoxy(26,48);
        cout<<"Do you want to delete more  (y/n)....";
        cin>>ch;

            if(ch == 'y' || ch=='Y')
            {
            goto delete_again;
            }
            else
            {
            goto dontdelete;
            }
    }


    dontdelete :
            clrscr();
            lines line;
               line.line_hor(1,80,3,223);
               line.line_hor(1,80,47,223);
               line.line_ver(1,50,4,219);
               line.line_ver(1,50,77,219);
    int j = 18;

    if( chek==1 || chek==-1 )
    {
        gotoxy(20,j+=2);
        cout<<"Press 'a' to return back to ADMIN menu...";
    }
    gotoxy(20,j+=2);
    cout<<"Press 'r' to return back to MAIN menu...";
    if( chek!=1 && chek!=-1 )
    {
        gotoxy(20,j+=2);
        cout<<"Press 'b' to return to PREVIOUS menu...";
    }
    gotoxy(20,j+=2);
    cout<<"Press 'e' to exit....";

    again5:

    char z ;
    z = getch();

    if(z=='a'&& ( chek==1 || chek==-1 ) )
       admin();
    else if(z=='r')
       start();
    else if(z== 'b' && ( chek!=1 && chek!=-1 ) )
       day();
    else if(z=='e')
       exit(-1);
    else
       goto again5;
}

void day()
{
textbackground(BLUE);
textcolor(WHITE);
clrscr();

   lines line;
   line.line_hor(1,80,3,223);
   line.line_hor(1,80,47,223);
   line.line_ver(1,50,4,219);
   line.line_ver(1,50,77,219);

train T;
char g;
gotoxy(7,15);
cout<<"Enter accordingly for time table of different days : \n"<<endl;
gotoxy(10,17);
cout<<"Press 1 for WEEKDAYS......";
gotoxy(10,19);
cout<<"Press 2 for WEEKENDS.....";
gotoxy(10,21);
cout<<"Press 'r' to return to main menu...";
gotoxy(10,23);
cout<<"Press 'e' to exit....";
gotoxy(10,25);
again3:
g=getch();

    switch(g)
    {
    case '1' :  weekday(0);   getch();       break;
    case '2' :  weekend(0);   getch();       break;
    case 'e' :  exit(0);        break;
    case 'r' :  start();         break;
    default  :  goto again3;
    }

}
void today_tt()
{
clrscr();
train T;
int x=16;

draw_table();
fstream f ( "train1.txt" , ios::in | ios::out);

    while ( !f.eof() )
    {

        f.read( (char*) &T, sizeof T );
        if( !f.eof() )
        {
        T.display(x);
        x+=3;
        }
    }
textcolor(WHITE+BLINK);
gotoxy(32,4);
cprintf("TODAY'S TIME TABLE ");

char c;
gotoxy(20,45);
cout<<"Press 'r' to return back to main menu...";
gotoxy(20,46);
cout<<"Press 'e' to exit....";
gotoxy(20,50);
gotoxy(79,50);
cout<<" ";
again:
c=getch();
f.close();
if(c=='r')
   start();
else if(c=='e')
   exit(-1);
else
   goto again;
}

void pass()
{
textcolor(WHITE);
clrscr();
&