The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)
Showing posts with label Algorithms. Show all posts
Showing posts with label Algorithms. Show all posts

Saturday, June 9, 2012

Finding the Saddle Point of Matrix


#include<conio.h>
#include<stdio.h>
#include<math.h>

int main()
  {
    int i,j,m,n,min;
    int mat[10][10];
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);

    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);            
      for(j=0;j<n;j++)
       scanf("%d",&mat[i][j]);  
    }
   
    for(i=0;i<m;i++)
    {
      min = 0;        
      for(j=1;j<n;j++)
      {
        if(mat[i][min] > mat[i][j])
         min = j;            
      }    
      for(j=0;j<m;j++)
      {
        if(mat[j][min] > mat[i][min])
         break;                            
      }
      printf("\n Row %d : ",i+1);
      if(j == m)
       printf("Saddle point exists at Column %d",min+1);
      else
       printf("Saddle point doesn't exists");    
    }    
    getch();
    return 0;
  }

Wednesday, June 6, 2012

Finding Skew-Symmetric Matrix


#include<conio.h>
#include<stdio.h>
#include<math.h>

int main()
  {
    int i,j,m,n,min;
    int mat[10][10];
    do
    {
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);
    }while(m!=n);

    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);          
      for(j=0;j<n;j++)
       scanf("%d",&mat[i][j]);  
    }
 
    for(i=1;i<m;i++)
    {        
     for(j=0;j<i;j++)
     {
       if(mat[i][j] != -mat[j][i])
        break;            
     }  
    }  
 
    if(i == m && j+1 == i)
     printf("\n\nIt is a Skew-Symmetric Matrix");
    else
     printf("\n\nIt is not a Skew-Symmetric Matrix");
    getch();
    return 0;
  }

Thursday, May 31, 2012

Finding the Equivalent Number at the Given Base


#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
  int i,b,e,tmp,nod=0;
  scanf("%d %d",&b,&e);
  tmp = b;
  while(tmp)
  {
    nod++;      
    tmp = tmp/e;          
  }
  printf("\n");
  while(nod>0)
  {  
   nod--;  
   tmp = 1;      
   for(i=0;i<nod;i++)
    tmp *= e;
   if(e != 16)
    printf("%d",b/tmp);
   else
   printf("%X",b/tmp);
 
   b %= tmp;      
  }
  getch();
  return 0;
}

Tuesday, May 29, 2012

Writing the Given Number in alphabets


#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
  int i,b,tmp,nod=0;
  scanf("%d",&b);
  tmp = b;
  while(tmp)
  {
    nod++;      
    tmp = tmp/10;          
  }
  printf("\n");
  while(nod>0)
  {  
   nod--;  
   tmp = 1;      
   for(i=0;i<nod;i++)
    tmp *= 10;
   switch(b/tmp)
   {
     case 0 : printf("Zero "); break;
     case 1 : printf("One "); break;
     case 2 : printf("Two "); break;
     case 3 : printf("Three "); break;
     case 4 : printf("Four "); break;
     case 5 : printf("Five "); break;
     case 6 : printf("Six "); break;
     case 7 : printf("Seven "); break;
     case 8 : printf("Eight "); break;
     case 9 : printf("Nine "); break;
     default: break;              
   }  
   b %= tmp;      
  }
  getch();
  return 0;
}

Sunday, May 27, 2012

Finding a 4-Digit Perfect Square Number of order AABB


#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
  int a=1,b=0,i,nm,nms;
  while(1)
  {
   
    nm = 0;
    for(i=1;i<=4;i++)
    {
     if(i<=2)              
      nm = nm*10 + a;
     else
      nm = nm*10 + b;
    }      
    nms = sqrt(nm);
    if(nm==(nms*nms))
    {
     printf("%d is Perfect Square Number of order AABB",nm);                    
     break;  
    }
    else
    {
     b = (++b)%10;
    if(b == a)
     b = (++b)%10;  
    if(b==0)
     ++a;  
    }
  }
  getch();
  return 0;
}

Sunday, May 13, 2012

Shamir's Secret Algorithm


#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#define max 6


int coef[max];
int mat[max][max];
int m;
int r;
int n;
int t;

struct key
{
 int x;
 int y;
}ky[max];

struct lag_poly
{
 float xc[max];
 int y;
 int x;
}lp[max+1];

int tmpx[max+1][max];
int tmp;

void in_dat()
{
 n = max;
 printf("\n Enter 't' : ");
 scanf("%d",&t);
 printf("\n Enter the secret 'm' : ");
 scanf("%d",&m);
 coef[0] = m;
 for(int i=1;i<t;i++)
 {
  printf("\n Enter coefficient for x^%d : ",i);
  scanf("%d",&coef[i]);
 }
}


void make_ply()
{
 int pw;
 for(int i=0;i<n;i++)
 {
  ky[i].y = 0;
  printf("\n\t Key %d\n Enter 'x%d': ",i+1,i);
  scanf("%d",&ky[i].x);
  for(int j=0;j<t;j++)
   ky[i].y += (coef[j]*pow(ky[i].x,j));
  printf("\n\t Key (x%d,y%d) : (%d,%d)",i,i,ky[i].x,ky[i].y);
 }
 getch();
}

void obt_ply(int opt)
{
 tmp=0;
 for(int i=0;i<t;i++)
 {
  if(i != opt)
  {
   tmpx[tmp][0] = (-1)*lp[i].x;
   tmpx[tmp][1] = 1;
   tmpx[tmp][2] = 0;
   for(int j=3;j<max;j++)
     tmpx[tmp][j] = 0;
   printf("\n%d\n",tmp);
   for(j=0;j<max;j++)
    printf(" %d",tmpx[tmp][j]);
   tmp++;
  }
 }
 for(int j=0;j<max;j++)
  tmpx[max][j] = 0;

 printf("\n tmp=%d\n",tmp);
 int in=0;
 while(in < tmp-1)
 {
  for(i=0;i<max;i++)
  {
   for(j=0;j<max;j++)
   {
    tmpx[max][i+j] +=  (tmpx[in][i] * tmpx[in+1][j]);
   }
  }
   printf("\n .. \n");
   for(j=0;j<max;j++)
    printf(" %d",tmpx[max][j]);
   getch();

  ++in;

   for(i=0;i<max;i++)
   {
    tmpx[in][i] = tmpx[max][i];
    tmpx[max][i] = 0;
   }
 }

  int prd = 1;
  for(i=0;i<t;i++)
  {
   if(i != opt)
    prd *= (lp[opt].x-lp[i].x);
  }

  printf("\n ..... res .......\n");
  for(j=0;j<max;j++)
  {
   lp[opt].xc[j] = (float) tmpx[in][j]/prd;
   printf(" %f",lp[opt].xc[j]);
  }
}

void lagrange()
{
 clrscr();
 int op;
 for(int i=0;i<t;i++)
 {
  printf("\n Enter Key to be regenerated :");
  scanf("%d",&op);
  lp[i].y = ky[op-1].y;
  lp[i].x = ky[op-1].x;

  for(int j=0;j<max;j++)
   lp[i].xc[j] = 0.0;
 }


 for(i=0;i<t;i++)
  obt_ply(i);

 for(int j=0;j<max;j++)
   lp[t].xc[j] = 0.0;

 for(i=0;i<t;i++)
 {
  for(j=0;j<max;j++)
   lp[t].xc[j] += (lp[i].y*lp[i].xc[j]);
 }

  getch();
  printf("\n\n\n\n .. Ans ...\n\n");
  for(j=0;j<max;j++)
   printf(" %f",lp[t].xc[j]);

 r = (int) (lp[t].xc[0]+0.5);
 printf("\n %d\n",r);
}

void main()
{
 clrscr();
 in_dat();
 make_ply();
 lagrange();
 getch();
}

Thursday, May 10, 2012

Tic-Tac Game



#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<iomanip.h>
#include<process.h>

int aut(int);
int au(int);
int bl(int);
void col1();
int in(int);
void col();
int vic(int,int);
void doc();
void close();
int dic(char,char,char,char,char);
int ino(int);
int inn(int);
void das();
void de(char);
void de2(char);
void pre(int);

void main()
{
int i,j,c,r;
int g=2;

clrscr();
for (i=2,j=63;j>68,i<28;i++,j--)
{
delay(70);
gotoxy(i,9);
cputs(" BINNY'S SOFTWARES");
gotoxy(j,11);
cputs("PRESENTS ");
}
 delay(4000);

clrscr();
gotoxy(25,5);
cputs("OOO    OO    OOO   OOOOOOOO    OOOO");
gotoxy(25,6);
cputs("OO O   OO   O   O    OOO     O     ");
gotoxy(25,7);
cputs("OO  O  OO  O     O   OOO      OOOO ");
gotoxy(25,8);
cputs("OO   O OO   O   O    OOO          O");
gotoxy(25,9);
cputs("OO     OO    OOO     OOO      OOOO ");

gotoxy(33,11);
cputs("     OO");
gotoxy(33,12);
cputs("    O  O");
gotoxy(33,13);
cputs("      O  ");
gotoxy(33,14);
cputs("    O   O  O");
gotoxy(33,15);
cputs("    O    O  ");
gotoxy(33,16);
cputs("     OOOO  O");

gotoxy(9,18);
cputs("      XXX  XXXXX    XXX    XXXX   XXXX  XXXXX  XXXXX   XXXXX");
gotoxy(9,19);
cputs("     X     X  X    X   X  X      X      X     X       X    ");
gotoxy(9,20);
cputs("    X      X X    X     X  XXXX   XXXX  XXXX   XXXXX   XXXXX ");
gotoxy(9,21);
cputs("     X     X   X   X   X       X      X X           X       X ");
gotoxy(9,22);
cputs("      XXX  X    X   XXX    XXXX   XXXX  XXXXX  XXXXX   XXXXX ");
delay(4000);

start:
das();
cout<<"\n\n 1.Play Nots & Crossess\n 2.Options\n 3.About\n 4.Help \n 5.Exit\
\n\n Enter your choice:";
cin>>c;
if (c==2)
{
clrscr();
doc();
gotoxy(35,4);
cout<<"Options\n\n 1. Colour of the game\n 2. Type of board\n 3. Back";
cout<<"\nEnter Your Choice:";
cin>>i;
if (i==3) goto start;

else if (i==1)
{
clrscr();
doc();
gotoxy(1,4);
textcolor(BLUE);
cputs("1:  BLUE");
gotoxy(1,5);
textcolor(GREEN);
cputs("2:  GREEN");
textcolor(RED);
gotoxy(1,6);
cputs("3:  RED");
textcolor(BROWN);
gotoxy(1,7);
cputs("4:  BROWN");
textcolor(BLACK);
gotoxy(1,8);
cputs("5:  BLACK");textcolor(WHITE);cputs("  (You can't see black in a black background)");
textcolor(CYAN);
gotoxy(1,9);
cputs("6:  CYAN");
textcolor(MAGENTA);
gotoxy(1,10);
cputs("7:  MAGENTA");
textcolor(LIGHTGRAY);
gotoxy(1,11);
cputs("8:  LIGHTGRAY");
textcolor(DARKGRAY);
gotoxy(1,12);
cputs("9:  DARKGRAY");
textcolor(LIGHTBLUE);
gotoxy(1,13);
cputs("10: LIGHTBLUE");
textcolor(LIGHTGREEN);
gotoxy(1,14);
cputs("11: LIGHTGREEN");
textcolor(LIGHTCYAN);
gotoxy(1,15);
cputs("12: LIGHTCYAN");
textcolor(LIGHTRED);
gotoxy(1,16);
cputs("13: LIGHTRED");
textcolor(LIGHTMAGENTA);
gotoxy(1,17);
cputs("14: LIGHTMAGENTA");
textcolor(YELLOW);
gotoxy(1,18);
cputs("15: YELLOW");
textcolor(WHITE);
gotoxy(1,19);
cputs("16: WHITE");
cout<<">> ";
cin>>r;
if(r == 1)
textcolor(BLUE);
else if(r == 2)
textcolor(GREEN);
else if(r == 3)
textcolor(RED);
else if(r == 4)
textcolor(BROWN);
else if(r == 5)
textcolor(BLACK);
else if(r == 6)
textcolor(CYAN);
else if(r == 7)
textcolor(MAGENTA);
else if(r == 8)
textcolor(LIGHTGRAY);
else if(r == 9)
textcolor(DARKGRAY);
else if(r == 10)
textcolor(LIGHTBLUE);
else if(r == 11)
textcolor(LIGHTGREEN);
else if(r == 12)
textcolor(LIGHTCYAN);
else if(r == 13)
textcolor(LIGHTRED);
else if(r == 14)
textcolor(LIGHTMAGENTA);
else if(r == 15)
textcolor(YELLOW);
else if(r == 16)
textcolor(WHITE);
goto start;
}
else if (i==2);
{
clrscr();
doc();
{
gotoxy(9,3);
cputs("Board No-1");

for(int i=3;i<24;i++)
{
gotoxy(i,7);
cputs("Ä");
}
for (i=3;i<24;i++)
{
gotoxy(i,10);
cputs("Ä");
}
for (i=5;i<14;i++)
{
gotoxy(8,i);
cputs("³");
}
for (i=5;i<14;i++)
{
gotoxy(18,i);
cputs("³");
}
gotoxy(8,7);
cputs("Å");
gotoxy(18,7);
cputs("Å");
gotoxy(8,10);
cputs("Å");
gotoxy(18,10);
cputs("Å");
gotoxy(7,5);
cputs("1");
gotoxy(17,5);
cputs("2");
gotoxy(24,5);
cputs("3");
gotoxy(7,8);
cputs("4");
gotoxy(17,8);
cputs("5");
gotoxy(24,8);
cputs("6");
gotoxy(7,11);
cputs("7");
gotoxy(17,11);
cputs("8");
gotoxy(24,11);
cputs("9");


for(i=44;i<67;i++)
{
gotoxy(i,7);
cputs("Ä");
gotoxy(i,10);
cputs("Ä");
}

for(i=44;i<67;i++)
{
gotoxy(i,4);
cputs("Ä");
gotoxy(i,13);
cputs("Ä");
}

for (i=4;i<14;i++)
{
gotoxy(51,i);
cputs("³");
gotoxy(60,i);
cputs("³");
}
for(i=4;i<13;i++)
{
gotoxy(67,i);
cputs("³");
gotoxy(44,i);
cputs("³");

}
gotoxy(51,7);
cputs("Å");
gotoxy(60,7);
cputs("Å");
gotoxy(51,10);
cputs("Å");
gotoxy(60,10);
cputs("Å");
gotoxy(67,4);
cputs("¿");
gotoxy(44,4);
cputs("Ú");
gotoxy(67,13);
cputs("Ù");
gotoxy(44,13);
cputs("À");
gotoxy(51,13);
cputs("Á");
gotoxy(60,13);
cputs("Á");
gotoxy(51,4);
cputs("Â");
gotoxy(60,4);
cputs("Â");
gotoxy(44,7);
cputs("Ã");
gotoxy(44,10);
cputs("Ã");
gotoxy(67,7);
cputs("´");
gotoxy(67,10);
cputs("´");


gotoxy(50,5);
cputs("1");
gotoxy(59,5);
cputs("2");
gotoxy(66,5);
cputs("3");
gotoxy(50,8);
cputs("4");
gotoxy(59,8);
cputs("5");
gotoxy(66,8);
cputs("6");
gotoxy(50,11);
cputs("7");
gotoxy(59,11);
cputs("8");
gotoxy(66,11);
cputs("9");
    // /*/
gotoxy(51,3);
cputs("Board No-2");
   //*/


}

gotoxy(1,17);
cout<<"Enter the type of Board you like\n";
cin>>g;
goto start;
}
//if (g==3) goto start;
}
if(c==1)
{
clrscr();
cout<<"\n\n"<<setw(45)<<"NOTS & CROSSESS\n"<<setw(46)<<"The gaming software";
cout<<"\n\n 1. Computer Vs Human\n 2. Human Vs Human\n 3. Back";
cout<<"\nEnter your choice:";
cin>>c;

if (c==1)
{
clrscr();
//COMP VS MAN (START)
int a;
char ch;
clrscr();
doc();
cout<<"\n\n Enter your Name:";
char name[10];
cin>>name;

do{
clrscr();
doc();
if (g==1)
col1();
else if (g==2)
col();
else col();
gotoxy(1,2);
cout<<name;
a=in(3);


if (a==5)              // START 5
{
 au(7);
 a=in(4);
 if (a==1)
  {
  au(9);
  a=in(5);
if(a==4)
{
vic(8,3);
goto end;
}
  else if (a==8)
   {
   au(2);
   a=in(6);
   if (a==3)
    {
     au(4);
     bl(6);
     goto end;
    }
    else if (a==4)
    {
     au(6);
     bl(3);
     goto end;
    }
    else if (a==6)
    {
     au(4);
     bl(3);
     goto end;
    }
  }
  else {vic(8,3);goto end;}
 }

 else if (a==2)
 {
  au(8);
  a=in(5);
  if (a==9)
   {
   au(1);
   a=in(6);
   if (a==4)
    {
    au(6);
    bl(3);
    goto end;
    }
   else if (a==3||a==6)  {vic(4,4);goto end;}
   }
   else {vic(9,3);goto end;}
  }
 else if (a==3)
  {
  au(9);
  a=in(5);
  if (a==8)
   {
   au(2);
   a=in(6);
   if (a==1)
    {
    au(4);
    bl(6);
    goto end;
    }
   else if (a==4)
    {
    au(6);
    bl(1);
    goto end;
    }
   else if (a==6)
    {
    au(4);
    bl(1);
    goto end;
    }
   else bl(a);      goto end;
   }
  else {vic(8,3);goto end;}
 }
 else if (a==4)
  {
  au(6);
  a=in(5);
  if (a==1)
   {
   au(9);
   a=in(6);
   if (a==8)
    {
    au(2);
    bl(3);
    goto end;
    }
   else {vic(8,3);goto end;}
   }
  else if (a==2)
   {
   au(8);
   a=in(6);
   if(a==9)
    {
    au(1);
    bl(3);
    goto end;
    }
   else {vic(9,3);goto end;}
   }
  else if(a==3)
   {
   au(9);
   a=in(6);
   if (a==8)
    {
    au(2);
    bl(1);goto end;
    }
   else {vic(8,3);goto end;}
   }
  else if (a==8)
   {
   au(2);
   a=in(6);
   if(a==1)
    {
    au(9);
    bl(3);
    goto end;
    }
   else if(a==9)
    {
    au(1);
    bl(3);
    goto end;
    }
  else if(a==3)
   {
   au(1);
   bl(9);
   goto end;
   }
  }
 else if(a==9)
  {
  au(1);
  a=in(6);
  if (a==2)
   {
   au(8);
   bl(3);
   goto end;
   }
  else if(a==3)
   {
   au(2);
   bl(8);
   goto end;
   }
  else if(a==8)
   {
   au(2);
   bl(3);
   goto end;
   }
  }
 }

 else if (a==6)
 {
 au(4);
 a=in(5);
 if(a==1)
  {
  au(9);
  a=in(6);
  if(a==8)
   {
   au(2);
   bl(3);
   goto end;
   }
  else {vic(8,3);goto end;}
  }
 else {vic(1,4);goto end;}
 }
 else if(a==8)
  {
  au(2);
  a=in(5);
  if(a==1)
   {
   au(9);
   a=in(6);
   if(a==4)
    {
    au(6);
    bl(3);
    goto end;
    }
   else if (a==6)
    {
    au(4);
    bl(3);
    goto end;
    }
   else if(a==3)
    {
    au(4);
    bl(6);
    goto end;
    }
   }
  else if (a==3)
   {
   au(1);
   a=in(6);
   if (a==4)
    {
    au(6);
    bl(9);goto end;
    }
   else {vic (4,4);goto end;}
   }
  else if(a==4)
   {
   au(6);
   a=in(6);
   if(a==1)
    {
    au(9);
    bl(3);goto end;
    }
   else if(a==3)
    {
    au(1);
    bl(9);goto end;
    }
   else if(a==9)
    {
    au(1);
    bl(3);goto end;
    }
   }
  else if (a==9)
   {
   au(1);
   a=in(6);
   if(a==4)
    {
    au(6);
    bl(3);goto end;
    }
   else {vic(4,4);goto end;}
   }
  else if (a==6)
   {
   au(4);
   a=in(6);
   if (a==1)
    {
    au(9);
    bl(3);goto end;
    }
   else {vic(1,4);goto end;}
   }
  }

 else if (a==8)
 {
 au(2);
 a=in(5);
 if (a==1)
  {
  au(9);
  a=in(6);
  if(a==4)
   {
   au(6);
   bl(3); goto end;
   }
  else if (a==6)
   {
   au(4);
   bl(3);goto end;
   }
  else if (a==3)
   {
   au(6);
   bl(4);      goto end;
   }
  }
  else if (a==3)
   {
   au(1);
   a=in(5);
   if (a==4)
    {
    au(6);
    bl(9);    goto end;
    }
   else {vic(4,4);goto end;}
   }
  else if (a==6)
   {
   au(4);
   bl(3);     goto end;
   }
  else if (a==9);
   {
   au(1);       goto end;
   }
  }

 else if (a==9)
  {
  au(1);
  a=in(5);
  if(a==4)
   {
   au(6);
   a=in(6);
   if(a==2)
    {
    au(8);
    bl(3);    goto end;
    }
   else if(a==3)
    {
    au(2);
    bl(8);    goto end;
    }
   else if(a==8)
    {
    au(2);
    bl(3);    goto end;
    }
   }
  else {vic(4,4);goto end;}
  }
  goto end;                //END 5
 }
else if(a==1)              //START 1
 {
 au(5);
 a=in(4);
 if(a==2)
  {
  au(3);
  a=in(5);
  if(a==7)
   {
   au(4);
   a=in(6);
   if(a==6)
    {
    au(8);
    bl(9);
    goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(7,8);goto end;}
  }

 else if(a==3)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(4);
   a=in(6);
   if(a==6)
    {
    au(9);
    bl(7);
    goto end;
    }
   else if(a==7||a==9) {vic(6,2);goto end;}
   else cout<<"GET OUT@#&$%%*^";
goto end;
   }
  else {vic(8,5);goto end;}
  }

 if(a==4)
  {
  au(7);
  a=in(5);
  if(a==3)
   {
   au(2);
   a=in(6);
   if(a==8)
    {
    au(9);
    bl(6);
    goto end;
    }
   else {vic(8,5);goto end;}
   }
  else {vic(3,8);goto end;}
  }

 if (a==6)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(7);
   a=in(6);
   if (a==3)
    {
    au(9);
    bl(4);
    goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 if(a==7)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(2);
   a=in(6);
   if (a==8)
    {
    au(9);
    bl(3);
    goto end;
    }
   else {vic(8,5);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if (a==8)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(3);
   a=in(6);
   if(a==7)
    {
    au(9);
    bl(2);
    goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==9)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(7);
   a=in(6);
   if(a==3)
    {
    au(6);
    bl(4);     goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(8,5);goto end;}
  }   goto end;
 }                                  //END 1


else if(a==2)   //START 2
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(3);
  a=in(5);
  if(a==7)
   {
   au(4);
   a=in(6);
   if (a==6)
    {
    au(8);
    bl(9);goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(7,8);goto end;}
  }

 else if(a==3)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(6);
   a=in(6);
   if(a==4)
    {
    au(7);
    bl(8);goto end;
    }
   else {vic(4,2);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==4)
  {
  au(3);
  a=in(5);
  if(a==7)
   {
   au(1);
   a=in(6);
   if (a==9)
    {
    au(8);
    bl(6);goto end;
    }
   else {vic(9,7);goto end;}
   }
  else {vic(7,8);goto end;}
  }

 else if(a==6)
  {
  au(9);
  a=in(5);
  if(a==1)
   {
   au(3);
   a=in(6);
   if(a==7)
    {
    au(4);
    bl(8);goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(1,7);goto end;}
  }

 else if(a==7)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(8);
   a=in(6);
   if(a==3)
    {
    au(6);
    bl(4);
    goto end;
    }
   else if(a==4)
    {
    au(6);
    bl(3);goto end;
    }
   else if(a==6)
    {
    au(3);
    bl(4); goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==8)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(3);
    bl(7);goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==9)
  {
  au(6);
  a=in(5);
  if(a==4)
   {
   au(7);
   a=in(6);
   if(a==3)
    {
    au(1);
    bl(8);goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(4,2);goto end;}
  }    goto end;
 }                                //END 2

else if (a==3)                    //START 3
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(4);
   a=in(6);
   if (a==6)
    {
    au(9);
    bl(7);goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(5,5);goto end;}
  }

 else if(a==2)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(6);
   a=in(6);
   if(a==4)
    {
    au(7);
    bl(8);goto end;
    }
   else {vic(4,2);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==4)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(9);
   a=in(6);
   if (a==1)
    {
    au(7);
    bl(6);goto end;
    }
   else {vic(5,7);goto end;}
   }
  else {vic(5,5);goto end;}
  }

 else if(a==6)
  {
  au(9);
  a=in(5);
  if(a==1)
   {
   au(2);
   a=in(6);
   if(a==8)
    {
    au(4);
    bl(7);goto end;
    }
   else {vic(5,5);goto end;}
   }
  else {vic(1,7);goto end;}
  }

 else if(a==7)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(4);
    bl(6);      goto end;
    }
  /* else if(a==4)
    {
    au(6);
    bl(3);
    }
   else if(a==6)
    {
    au(3);
    bl(4);
    } */
   else {vic(5,7);goto end;}
   }
  else {vic(5,5);goto end;}
  }

 else if(a==8)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(2);
    bl(7);   goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==9)
  {
  au(6);
  a=in(5);
  if(a==4)
   {
   au(8);
   a=in(6);
   if(a==2)
    {
    au(1);
    bl(7);    goto end;
    }
   else {vic(2,5);goto end;}
   }
  else {vic(4,2);goto end;}
  }        goto end;
 }                                //END 3

 if (a==4)                       //START 4
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(7);
  a=in(5);
  if(a==3)
   {
   au(2);
   a=in(6);
   if (a==8)
    {
    au(9);
    bl(6);goto end;
    }
   else {vic(8,5);goto end;}
   }
  else {vic(3,8);goto end;}
  }

 else if(a==2)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(3);
   a=in(6);
   if(a==7)
    {
    au(8);
    bl(6);goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==3)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(9);
   a=in(6);
   if (a==1)
    {
    au(7);
    bl(6);   goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 else if(a==6)
  {
  au(9);
  a=in(5);
  if(a==1)
   {
   au(7);
   a=in(6);
   if(a==8)
    {
    au(3);
    vic(3,8);goto end;
    }
   else {vic(7,3);goto end;}
   }
  else {vic(1,7);goto end;}
  }

 else if(a==7)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(8);
   a=in(6);
   if(a==2)
    {
    au(3);
    bl(6);  goto end;
    }
   else {vic(2,5);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==8)
  {
  au(7);
  a=in(5);
  if(a==3)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(2);
    bl(6);  goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(3,8);goto end;}
  }

 else if(a==9)
  {
  au(8);
  a=in(5);
  if(a==2)
   {
   au(3);
   a=in(6);
   if(a==7)
    {
    au(1);
    bl(6);  goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(2,5);goto end;}
  }    goto end;
 }                                //END 4

if (a==6)                    //START 6
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(7);
   a=in(6);
   if (a==3)
    {
    au(9);
    bl(4);  goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 else if(a==2)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(3);
   a=in(6);
   if(a==7)
    {
    au(8);
    bl(6);  goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==3)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(9);
   a=in(6);
   if (a==1)
    {
    au(7);
    bl(4);  goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 else if(a==4)
  {
  au(9);
  a=in(5);
  if(a==1)
   {
   au(7);
   a=in(6);
   if(a==8)
    {
    au(3);
    vic(3,8);
    }
   else {vic(7,3);goto end;}
   }
  else {vic(1,7);goto end;}
  }

 else if(a==7)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(4);
    bl(3);  goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 else if(a==8)
  {
  au(7);
  a=in(5);
  if(a==3)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(2);
    bl(4);  goto end;
    }
   else vic(1,7);
   }
  else vic(3,8);
  }

 else if(a==9)
  {
  au(3);
  a=in(5);
  if(a==7)
   {
   au(8);
   a=in(6);
   if(a==2)
    {
    au(1);
    bl(4);    goto end;
    }
   else vic(2,5);
   }
  else vic(7,8);
  }
 }                                //END 6

 if (a==7)                    //START 7
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(2);
   a=in(6);
   if (a==8)
    {
    au(9);
    bl(3);      goto end;
    }
   else {vic(8,5);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==2)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(3);
    bl(8);     goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==3)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(9);
   a=in(6);
   if (a==1)
    {
    au(4);
    bl(6);    goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 else if(a==4)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(8);
   a=in(6);
   if(a==2)
    {
    au(6);
    bl(3);   goto end;
    }
   else {vic(2,5);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==6)
  {
  au(8);
  a=in(5);
  if(a==2)
   {
   au(1);
   a=in(6);
   if(a==9)
    {
    au(3);
    bl(4);      goto end;
    }
   else {vic(9,7);goto end;}
   }
  else {vic(2,5);goto end;}
  }

 else if(a==8)
  {
  au(9);
  a=in(5);
  if(a==1)
   {
   au(4);
   a=in(6);
   if(a==6)
    {
    au(3);
    bl(2);      goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(1,7);goto end;}
  }

 else if(a==9)
  {
  au(8);
  a=in(5);
  if(a==2)
   {
   au(4);
   a=in(6);
   if(a==6)
    {
    au(3);
    bl(1);     goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(2,5);goto end;}
  }   //END 7
 }

 if (a==8)                 //START 8
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(3);
   a=in(6);
   if (a==7)
    {
    au(9);
    bl(2);goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==2)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(3);
    bl(7);goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==3)
  {
  au(6);
  a=in(5);
  if(a==4)
   {
   au(1);
   a=in(6);
   if (a==9)
    {
    au(7);
    bl(2);goto end;
    }
   else {vic(9,7);goto end;}
   }
  else {vic(4,2);goto end;}
  }

 else if(a==4)
  {
  au(1);
  a=in(5);
  if(a==9)
   {
   au(7);
   a=in(6);
   if(a==3)
    {
    au(6);
    bl(2);goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(9,7);goto end;}
  }

 else if(a==6)
  {
  au(3);
  a=in(5);
  if(a==7)
   {
   au(9);
   a=in(6);
   if(a==1)
    {
    au(4);
    bl(2);goto end;
    }
   else {vic(1,7);goto end;}
   }
  else {vic(7,8);goto end;}
  }

 else if(a==7)
  {
  au(9);
  a=in(5);
  if(a==1)
   {
   au(4);
   a=in(6);
   if(a==6)
    {
    au(3);
    bl(2);goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(1,7);goto end;}
  }

 else if(a==9)
  {
  au(7);
  a=in(5);
  if(a==3)
   {
   au(6);
   a=in(6);
   if(a==4)
    {
    au(2);
    bl(1);goto end;
    }
   else {vic(4,2);goto end;}
   }
  else {vic(3,8);goto end;}
  }
 }
    //END 8
 if (a==9)                    //START 9
 {
 au(5);
 a=in(4);
 if(a==1)
  {
  au(2);
  a=in(5);
  if(a==8)
   {
   au(7);
   a=in(6);
   if (a==3)
    {
    au(6);
    bl(4);goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(8,5);goto end;}
  }

 else if(a==2)
  {
  au(4);
  a=in(5);
  if(a==6)
   {
   au(7);
   a=in(6);
   if(a==3)
    {
    vic(1,4);goto end;
    }
   else {vic(3,8);goto end;}
   }
  else {vic(6,2);goto end;}
  }

 else if(a==3)
  {
  au(6);
  a=in(5);
  if(a==4)
   {
   au(8);
   a=in(6);
   if (a==2)
    {
    au(1);
    bl(7);goto end;
    }
   else {vic(2,5);goto end;}
   }
  else {vic(4,2);goto end;}
  }

 else if(a==4)
  {
  au(8);
  a=in(5);
  if(a==2)
   {
   au(3);
   a=in(6);
   if(a==7)
    {
    au(1);
    bl(6);goto end;
    }
   else {vic(7,8);goto end;}
   }
  else {vic(2,5);goto end;}
  }

 else if(a==6)
  {
  au(3);
  a=in(5);
  if(a==7)
   {
   au(8);
   a=in(6);
   if(a==2)
    {
    au(4);
    bl(1);goto end;
    }
   else {vic(2,5);goto end;}
   }
  else {vic(7,8);goto end;}
  }

 else if(a==7)
  {
  au(8);
  a=in(5);
  if(a==2)
   {
   au(4);
   a=in(6);
   if(a==6)
    {
    au(3);
    bl(1);goto end;
    }
   else {vic(6,2);goto end;}
   }
  else {vic(2,5);goto end;}
  }

 else if(a==8)
  {
  au(7);
  a=in(5);
  if(a==3)
   {
   au(6);
   a=in(6);
   if(a==4)
    {
    au(2);
    bl(1);goto end;
    }
   else {vic(4,2);goto end;}
   }
  else {vic(3,8);goto end;}
  }       //END 9
 }

else
goto end;                            //END ALL


end:
gotoxy(28,24);
cputs("Do you want to play again?(Y/N)");
cin>>ch;
}
while(ch=='y'||ch=='Y');
goto start;                         //COMP VS MAN (END)
}


else if (c==2)                 //MAN VS MAN (START)
{
char n1[10],n2[10],ch;
men:
das();
gotoxy(1,5);
cout<<"Enter the name of player 1:";
cin>>n1;
gotoxy(1,6);
cout<<"Enter the name of player 2:";
cin>>n2;

char a;
do{
doc();
if (g==1)
col1();
else if (g==2)
col();
else col();
char p1[5],p2[5],q;
for(i=0;i<5;i++)
{
p1[i]='0';
p2[i]='0';
}
gotoxy(2,2);
cout<<n1;
gotoxy(67,2);
cout<<n2;
p1[0]=ino(3);
p2[0]=inn(3);
p1[1]=ino(4);
p2[1]=inn(4);
p1[2]=ino(5);
q=dic(p1[0],p1[1],p1[2],p1[3],p1[4]);
if (q==1)
{
gotoxy(1,16);
cout<<n1<<" wins! Good playing. Concragulations "<<n1;
goto mend;
}
p2[2]=inn(5);
q=dic(p2[0],p2[1],p2[2],p2[3],p2[4]);
if (q==1)
{
gotoxy(1,16);
cout<<n2<<" wins! Good playing. Concragulations "<<n2;
goto mend;
}
p1[3]=ino(6);
q=dic(p1[0],p1[1],p1[2],p1[3],p1[4]);
if (q==1)
{
gotoxy(1,16);
cout<<n1<<" wins! Good playing. Concragulations "<<n1;
goto mend;
}
p2[3]=inn(6);
q=dic(p2[0],p2[1],p2[2],p2[3],p2[4]);
if (q==1)
{
gotoxy(1,16);
cout<<n2<<" wins! Good playing. Concragulations "<<n2;
goto mend;
}
p1[4]=ino(7);
q=dic(p1[0],p1[1],p1[2],p1[3],p1[4]);
if (q==1)
{
gotoxy(1,16);
cout<<n1<<" wins! Good playing. Concragulations "<<n1;
goto mend;
}
q=dic(p2[0],p2[1],p2[2],p2[3],p2[4]);
if (q==1)
{
gotoxy(1,16);
cout<<n2<<" wins! Good playing. Concragulations "<<n2;
goto mend;
}
mend:
gotoxy(35,22);
cout<<"Game Over\nWant to play again(Y/N)";
cin>>ch;
}
while (ch=='y'||ch=='Y');
goto start;
}      //MAN VS MAN (END)





else goto start;
}

else if(c==3)
{
clrscr();
cout<<"\n\n"<<setw(45)<<"NOTS & CROSSESS\n"<<setw(46)<<"The gaming software";
cout<<"\n\n\t\tDevoleped By Binny in C++\n\n\t\tFor more \
information come to www.binnyva.bizland.com/pro\n\n\tI would love to here from\
you. Write to me at binnyvabraham@usa.net";
gotoxy(8,20);
cout<<"1. Acknoledgements\n";
gotoxy(8,21);
cout<<"2. Back\nEnter your choice:";
int r;
cin>>r;
if (r==1)
{
gotoxy(1,12);
cout<<" First of all I would like to thank God for this marvallous achivement\
. With out  His help I would never have made such a software. \n Next I would \
like to thank my parents for their encouragement and support.\n Then I would like \
to thank my brother for his test plays and his encouragement. Last but not \
the least I would like to thank you for playing this game which is not even \
worth counting in this compatitive world. Thank You!";
getch();
goto start;
}
else goto start;
}
else if(c==4)
{
clrscr();
doc();
gotoxy(1,17);
cout<<" This is the computer version of the popular game Nots and Crosses \
which is also\n called as Tic Tac Toe. \n Rules: A player choces any coloum\
chosing the corresponding digit. His symbol\n (X/O) appears in the coloum.\
The next player does the same. This will be\n repeated till all the coloums are\
occupied.\n To win: A Player must capture three corresponding coloums such as\
 1,2,3.\n Press  any key to see the diffrent winning boards\n ";
getch();
col();
au(1);
au(2);
au(3);
gotoxy(2,25);
cout<<"Press a key to goto next board";
getch();
clrscr();
col();
aut(1);
aut(4);
aut(7);
gotoxy(2,24);
cout<<"Press a key to go to next board";
getch();
clrscr();
col();
aut(1);
aut(5);
aut(9);
gotoxy(2,24);
cout<<"Press a key to go to next board";
getch();
clrscr();
col();
aut(2);
aut(5);
aut(8);
gotoxy(2,24);
cout<<"Press a key to go to next board";
getch();

clrscr();
col();
aut(4);
aut(5);
aut(6);
gotoxy(2,24);
cout<<"Press a key to go to next board";
getch();

clrscr();
col();
aut(3);
aut(6);
aut(9);
gotoxy(2,24);
cout<<"Press a key to go to next board";
getch();

clrscr();
col();
aut(8);
aut(7);
aut(9);
gotoxy(2,24);
cout<<"Press a key to go to next board";
getch();

clrscr();
col();
aut(7);
aut(5);
aut(3);
gotoxy(2,24);
cout<<"Press a key to go to Main menu";
getch();
goto start;
}

else if (c==5)
{
clrscr();
textcolor(WHITE);
cout<<"\n\n"<<setw(45)<<"NOTS & CROSSESS\n"<<setw(46)<<"The gaming software";
close();
}

getch();
}                                   //END ALL




void das()
{
clrscr();
cout<<"\n\n"<<setw(45)<<"NOTS & CROSSESS\n"<<setw(46)<<"The gaming software";
}


void doc()
{
clrscr();
cout<<setw(45)<<"NOTS & CROSSESS\n"<<setw(46)<<"The gaming software";
}

//void das()
//{
//clrscr();
//cout<<"\n\n"<<setw(45)<<"NOTS & CROSSESS\n"<<setw(46)<<"The gaming software";
//}

int ino(int d)
{
char a;
gotoxy(1,d);
cputs("Enter your choice:");
row:
cin>>a;
switch(a)
{
case '1':gotoxy(27,6);break;
case '2':gotoxy(35,6);break;
case '3':gotoxy(43,6);break;
case '4':gotoxy(27,9);break;
case '5':gotoxy(35,9);break;
case '6':gotoxy(43,9);break;
case '7':gotoxy(27,12);break;
case '8':gotoxy(35,12);break;
case '9':gotoxy(43,12);break;
default:{
gotoxy(1,15);
cout<<"Wrong Choice!! Enter again:";
goto row;
}
}
cputs("O");
return(a);
}

int inn(int d)
{
char a;
gotoxy(60,d);
cputs("Enter your choice:");
raw:
cin>>a;
switch(a)
{
case '1':gotoxy(27,6);break;
case '2':gotoxy(35,6);break;
case '3':gotoxy(43,6);break;
case '4':gotoxy(27,9);break;
case '5':gotoxy(35,9);break;
case '6':gotoxy(43,9);break;
case '7':gotoxy(27,12);break;
case '8':gotoxy(35,12);break;
case '9':gotoxy(43,12);break;
default:{gotoxy(50,15);cout<<"Wrong Choice!! Enter again:";goto raw;}
}
cputs("X");
return(a);
}


int aut(int a)
{
switch(a)
{
case 1:gotoxy(27,6);break;
case 2:gotoxy(35,6);break;
case 3:gotoxy(43,6);break;
case 4:gotoxy(27,9);break;
case 5:gotoxy(35,9);break;
case 6:gotoxy(43,9);break;
case 7:gotoxy(27,12);break;
case 8:gotoxy(35,12);break;
case 9:gotoxy(43,12);break;
case 13:{gotoxy(3,17);cout<<"You Won. Human supemacey still existing!!!";}
default:{cout<<"Wrong Choice!! Get out@#$%&*!";exit(0);}
}
cputs("O");
return(0);
}


int au(int a)
{
delay(300);
switch(a)
{
case 1:gotoxy(27,6);break;
case 2:gotoxy(35,6);break;
case 3:gotoxy(43,6);break;
case 4:gotoxy(27,9);break;
case 5:gotoxy(35,9);break;
case 6:gotoxy(43,9);break;
case 7:gotoxy(27,12);break;
case 8:gotoxy(35,12);break;
case 9:gotoxy(43,12);break;
case 13:{gotoxy(3,17);cout<<"You Won. Human supemacey still existing!!!";}
default:{cout<<"Wrong Choice!! Get out@#$%&*!";exit(0);}
}
cputs("X");
gotoxy(72,3);
cputs("I play ");
cout<<a;
return(0);
}


int bl(int b)
{
switch(b)
{
case 1:gotoxy(27,6);break;
case 2:gotoxy(35,6);break;
case 3:gotoxy(43,6);break;
case 4:gotoxy(27,9);break;
case 5:gotoxy(35,9);break;
case 6:gotoxy(43,9);break;
case 7:gotoxy(27,12);break;
case 8:gotoxy(35,12);break;
case 9:gotoxy(43,12);break;
default:{cout<<"Wrong Choice!! Get out@#$%&*!";exit(0);}
}
cputs("O");
gotoxy(1,15);
cputs("Remaining Move is ");
cout<<b;
gotoxy(1,16);
cputs("All moves over");
gotoxy(1,17);
cputs("Its a draw!");
gotoxy(1,18);
return(0);
}


int in(int d)
{
int a;
gotoxy(1,d);
cputs("Enter your choice:");
cin>>a;
switch(a)
{
case 1:gotoxy(27,6);break;
case 2:gotoxy(35,6);break;
case 3:gotoxy(43,6);break;
case 4:gotoxy(27,9);break;
case 5:gotoxy(35,9);break;
case 6:gotoxy(43,9);break;
case 7:gotoxy(27,12);break;
case 8:gotoxy(35,12);break;
case 9:gotoxy(43,12);break;
case 13:{gotoxy(3,17);cout<<"You Won. Human supemacey still existing!!!";
getch();exit(0);}
default:{cout<<"Wrong Choice!! Get out@#$%&*!";exit(0);}
}
cputs("O");
return(a);
}


int vic(int a,int b)
{
switch(b)
{
case 1: textcolor(WHITE+BLINK);
gotoxy(27,6);
cputs("X");
gotoxy(35,6);
cputs("X");
gotoxy(43,6);
cputs("X");
break;
case 2: textcolor(WHITE+BLINK);
gotoxy(27,9);
cputs("X");
gotoxy(35,9);
cputs("X");
gotoxy(43,9);
cputs("X");
break;
case 3: textcolor(WHITE+BLINK);
gotoxy(27,12);
cputs("X");
gotoxy(35,12);
cputs("X");
gotoxy(43,12);
cputs("X");
break;
case 4: textcolor(WHITE+BLINK);
gotoxy(27,6);
cputs("X");
gotoxy(27,9);
cputs("X");
gotoxy(27,12);
cputs("X");
break;
case 5: textcolor(WHITE+BLINK);
gotoxy(35,6);
cputs("X");
gotoxy(35,9);
cputs("X");
gotoxy(35,12);
cputs("X");
break;
case 6: textcolor(WHITE+BLINK);
gotoxy(43,6);
cputs("X");
gotoxy(43,9);
cputs("X");
gotoxy(43,12);
cputs("X");
break;
case 7: textcolor(WHITE+BLINK);
gotoxy(27,6);
cputs("X");
gotoxy(35,9);
cputs("X");
gotoxy(43,12);
cputs("X");
break;
case 8: textcolor(WHITE+BLINK);
gotoxy(43,6);
cputs("X");
gotoxy(35,9);
cputs("X");
gotoxy(27,12);
cputs("X");
break;
default:cout<<"Wrong choice";
}
textcolor(LIGHTGRAY);
gotoxy(1,13);
cputs("I play ");
cout<<a;
gotoxy(1,15);
cputs("Bet ya..");
gotoxy(1,16);
cputs("The coputer has beaten the human");
return (0);
}

void col1()
{

for(int i=25;i<46;i++)
{
gotoxy(i,7);
cputs("Ä");
}
for (i=25;i<46;i++)
{
gotoxy(i,10);
cputs("Ä");
}
for (i=5;i<14;i++)
{
gotoxy(30,i);
cputs("³");
}
for (i=5;i<14;i++)
{
gotoxy(40,i);
cputs("³");
}
gotoxy(30,7);
cputs("Å");
gotoxy(40,7);
cputs("Å");
gotoxy(30,10);
cputs("Å");
gotoxy(40,10);
cputs("Å");
gotoxy(29,5);
cputs("1");
gotoxy(39,5);
cputs("2");
gotoxy(46,5);
cputs("3");
gotoxy(29,8);
cputs("4");
gotoxy(39,8);
cputs("5");
gotoxy(46,8);
cputs("6");
gotoxy(29,11);
cputs("7");
gotoxy(39,11);
cputs("8");
gotoxy(46,11);
cputs("9");
}

void col()
{
for(int i=24;i<47;i++)
{
gotoxy(i,7);
cputs("Ä");
gotoxy(i,10);
cputs("Ä");
}

for(i=24;i<47;i++)
{
gotoxy(i,4);
cputs("Ä");
gotoxy(i,13);
cputs("Ä");
}

for (i=4;i<14;i++)
{
gotoxy(31,i);
cputs("³");
gotoxy(40,i);
cputs("³");
}
for(i=4;i<13;i++)
{
gotoxy(47,i);
cputs("³");
gotoxy(24,i);
cputs("³");

}
gotoxy(31,7);
cputs("Å");
gotoxy(40,7);
cputs("Å");
gotoxy(31,10);
cputs("Å");
gotoxy(40,10);
cputs("Å");
gotoxy(47,4);
cputs("¿");
gotoxy(24,4);
cputs("Ú");
gotoxy(47,13);
cputs("Ù");
gotoxy(24,13);
cputs("À");
gotoxy(31,13);
cputs("Á");
gotoxy(40,13);
cputs("Á");
gotoxy(31,4);
cputs("Â");
gotoxy(40,4);
cputs("Â");
gotoxy(24,7);
cputs("Ã");
gotoxy(24,10);
cputs("Ã");
gotoxy(47,7);
cputs("´");
gotoxy(47,10);
cputs("´");


gotoxy(30,5);
cputs("1");
gotoxy(39,5);
cputs("2");
gotoxy(46,5);
cputs("3");
gotoxy(30,8);
cputs("4");
gotoxy(39,8);
cputs("5");
gotoxy(46,8);
cputs("6");
gotoxy(30,11);
cputs("7");
gotoxy(39,11);
cputs("8");
gotoxy(46,11);
cputs("9");

}

void close()
{
int i,j;
for(j=13,i=20;j>6,i<42;j--,i++)
{
delay(70);
gotoxy(i,6);
cputs("Í");
gotoxy(i,13);
cputs("Í");
}
for(j=13;j>6;j--)
{
delay(70);
gotoxy(19,j);
cputs("º");
gotoxy(42,j);
cputs("º");
}
gotoxy(19,6);
cputs("É");
gotoxy(42,6);
cputs("»");
gotoxy(19,13);
cputs("È");
gotoxy(42,13);
cputs("¼");
gotoxy (20,7);
cputs("Thank");
gotoxy (26,7);
delay(250);
cputs("you");
gotoxy (30,7);
cputs("for");
delay(250);
gotoxy(34,7);
cputs("playing.");
delay(250);
gotoxy(20,9);
cputs("Hope you enjoyed. ");
gotoxy (20,11);
delay(250);
cputs("Write to me at");
gotoxy(20,12);
delay(250);
cputs("binnyvabraham@usa.net");
gotoxy (25,25);
cputs("Hit any key");


}

void de(char a)
{
delay(1000);
switch(a)
{
case '1':gotoxy(27,6);break;
case '2':gotoxy(35,6);break;
case '3':gotoxy(43,6);break;
case '4':gotoxy(27,9);break;
case '5':gotoxy(35,9);break;
case '6':gotoxy(43,9);break;
case '7':gotoxy(27,12);break;
case '8':gotoxy(35,12);break;
case '9':gotoxy(43,12);break;
default:{gotoxy(50,15);cout<<"Wrong Choice!!";}
}
cputs("O");
}

void de2(char a)
{
delay(1000);
switch(a)
{
case '1':gotoxy(27,6);break;
case '2':gotoxy(35,6);break;
case '3':gotoxy(43,6);break;
case '4':gotoxy(27,9);break;
case '5':gotoxy(35,9);break;
case '6':gotoxy(43,9);break;
case '7':gotoxy(27,12);break;
case '8':gotoxy(35,12);break;
case '9':gotoxy(43,12);break;
default:{gotoxy(3,15);cout<<"akjdfjadfj";delay(1000);cout<<"Wrong Choice!!";}
}
cputs("X");
/*else if(b==2)
cputs("O");*/
}


int dic (char p,char q,char r,char s,char t)                          //HERE HERE HERE HERE
{
int m=0;
if((p=='1')||(q=='1')||(r=='1')||(s=='1')||(t=='1'))
 {
 if((q=='2')||(p=='2')||(r=='2')||(s=='2')||(t=='2'))
  {
   if((r=='3')||(p=='3')||(q=='3')||(s=='3')||(t=='3'))
   m=1;
  }
 else if(q=='4'||p=='4'||r=='4'||s=='4'||t=='4')
  {
   if(r=='7'||p=='7'||q=='7'||s=='7'||t=='7')
   m=1;
  }
 else if(p=='5'||q=='5'||r=='5'||s=='5'||t=='5')
  {
   if(p=='9'||q=='9'||r=='9'||s=='9'||t=='9')
   m=1;
  }
 }

else if ((p=='2')||(q=='2')||(r=='2')||(s=='2')||(t=='2'))
 {
  if ((p=='5')||(q=='5')||(r=='5')||(s=='5')||(t=='5'))
{
if ((p=='8')||(q=='8')||(r=='8')||(s=='8')||(t=='8'))
m=1;
}
}

else if ((p=='3')||(q=='3')||(r=='3')||(s=='3')||(t=='3'))
{
if((p=='6')||(q=='6')||(r=='6')||(s=='6')||(t=='6'))
{
if((p=='9')||(q=='9')||(r=='9')||(s=='9')||(t=='9'))
m=1;
}
else if((p=='5')||(q=='5')||(r=='5')||(s=='5')||(t=='5'))
{
if((p=='7')||(q=='7')||(r=='7')||(s=='7')||(t=='7'))
m=1;
}
}

else if((p=='4')||(q=='4')||(r=='4')||(s=='4')||(t=='4'))
{
if((p=='5')||(q=='5')||(r=='5')||(s=='5')||(t=='5'))
{
if((p=='6')||(q=='6')||(r=='6')||(s=='6')||(t=='6'))
m=1;
}
}

else if((p=='7')||(q=='7')||(r=='7')||(s=='7')||(t=='7'))
{
if((p=='8')||(q=='8')||(r=='8')||(s=='8')||(t=='8'))
{
if((p=='9')||(q=='9')||(r=='9')||(s=='9')||(t=='9'))
m=1;
}
}
return(m);
}

void pre (int a)
{
switch(a)
{
case 4:{
vic(8,3);
break;
}
default:cout<<"";
}
}


Wednesday, May 9, 2012

Ordered List


#include<iostream.h>
#include<conio.h>

struct list
{
 int node;
 struct list *nxt;
};

class linked_list
{
 public:
  struct list *start;
  int nol;
   linked_list();
  ~linked_list();
  void insert_node();
  void delete_node();
  void display_list();
};

void linked_list :: linked_list()
{
  nol = 0;
  start = NULL;
}

void linked_list :: ~linked_list()
{
  nol = 0;
  struct list *nptr;
  nptr = start;
  start = NULL;
  delete nptr;
}

void linked_list :: insert_node()
{
 struct list *nptr;
 nptr = new list;
 cout<<"\n Enter the New Node to be Inserted : ";
 cin>>nptr->node;
 nptr->nxt = NULL;

 if(start == NULL)
  start = nptr;
 else
 {
  nptr->nxt = start;
  start = nptr;
 }
 nol += 1;
 cout<<"\n The Node has been Inserted into the List ";
 getch();
}


void linked_list :: delete_node()
{
 if(nol == 0)
  cout<<"\n WARNING !! No more Nodes in the List \n";
 else
 {
 struct list *loc,*locp,*nptr;
 int info;
 cout<<"\n Enter the Node to be Deleted : ";
 cin>>info;
 locp = NULL;
 loc = start;
 while(loc->node != info && loc != NULL)
 {
   locp = loc;
   loc = loc->nxt;
 }
 if(loc == NULL)
  cout<<"\n The Node is not present in the List ";
 else
 {
  nptr = new list;
  if(loc == start)
  {
   nptr = start;
   start = start->nxt;
  }
  else
  {
   nptr = loc;
   locp->nxt = loc->nxt;
  }
  nol -= 1;
  delete nptr;
  cout<<"\n The Node has been Deleted from the List ";
 }
 }
 getch();
}


void linked_list :: display_list()
{
 struct list *ptr;
 cout<<"\n The Linked List : \n\t";
 ptr = start;
 while(ptr != NULL)
 {
  cout<<ptr->node<<" -> ";
  ptr = ptr->nxt;
 }
 cout<<"NULL\n";
 cout<<"\n The Numer of Nodes in this List : "<<nol;
 getch();
}

class ord_linked_list : public linked_list
{
 public:
  ord_linked_list();
  ~ord_linked_list();
  void insert_node();
  void delete_node();
  void display_list();
};

void ord_linked_list :: ord_linked_list()
{
  linked_list::linked_list();
}

void ord_linked_list :: ~ord_linked_list()
{
  linked_list::~linked_list();
}

void ord_linked_list :: insert_node()
{
 struct list *nptr;
 nptr = new list;
 cout<<"\n Enter the New Node to be Inserted : ";
 cin>>nptr->node;
 nptr->nxt = NULL;

 if(start == NULL)
  start = nptr;
 else
 {
  struct list *loc,*locp;
  locp = NULL;
  loc = start;
  while(loc != NULL && loc->node <= nptr->node)
  {
   locp = loc;
   loc = loc->nxt;
  }
  if(loc == NULL)
   locp->nxt = nptr;
  else if(loc == start)
  {
   nptr->nxt = start;
   start = nptr;
  }
  else
  {
   locp->nxt = nptr;
   nptr->nxt = loc;
  }
 }
 nol += 1;
 cout<<"\n The Node has been Inserted into the List ";
 getch();
}


void ord_linked_list :: delete_node()
{
 linked_list::delete_node();
}


void ord_linked_list :: display_list()
{
 linked_list :: display_list();
}

void main()
{
 int cho;
 linked_list ll;
 linked_list();
 do
 {
 clrscr();
 cout<<"\n.. UNORDERED LINKED LIST MENU ..\n";
 cout<<"\n 1. Insert a node";
 cout<<"\n 2. Delete a node";
 cout<<"\n\n  Enter an option : ";
 cin>>cho;
 switch(cho)
 {
  case 1 :  ll.insert_node();
   break;
  case 2 :  ll.delete_node();
   break;
  default:  break;
 }
 ll.display_list();
 }while(cho == 1 || cho == 2);
 getch();


 clrscr();
 ord_linked_list oll;
 ord_linked_list();
 do
 {
 clrscr();
 cout<<"\n.. ORDERED LINKED LIST MENU ..\n";
 cout<<"\n 1. Insert a node";
 cout<<"\n 2. Delete a node";
 cout<<"\n\n  Enter an option : ";
 cin>>cho;
 switch(cho)
 {
  case 1 :  oll.insert_node();
   break;
  case 2 :  oll.delete_node();
   break;
  default:  break;
 }
 oll.display_list();
 }while(cho == 1 || cho == 2);
 getch();
}