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 ;)

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;
}

Tuesday, May 15, 2012

Matlab 2


close all;
clear all;
C1=0.199*10^(-12);
C2=34.91*10^(-12);
C3=0.199*10^(-12);
L1=127*10^(-9);
L2=0.726*10^(-9);
L3=127*10^(-9);
S21=[];
S11=[];
F=[];
z=50;
for f=1:10^7:2*10^9
    w=2*pi*f;
    mat1=[1 j*w*L1;0 1];
    mat2=[1 1/(j*w*C1);0 1];
    mat3=[1 0;1/(j*w*L2) 1];
    mat4=[1 0;j*w*C2 1];
    mat5=[1 j*w*L3;0 1];
    mat6=[1 1/(j*w*C3);0 1];
    matf=mat1*mat2*mat3*mat4*mat5*mat6;
    a=matf(1,1);
    b=matf(1,2);
    c=matf(2,1);
    d=matf(2,2);
    S21=[S21 ; 2/(a+b/z+c*z+d)];
    S11=[S11 ; (a+b/z-c*z-d)/(a+b/z+c*z+d)];
    F=[F ;f];
end
plot(F,abs(S21),'r',F,abs(S11),'g');

Matlab 1


close all;
clear all;
C1=0.984*10^(-12);
L2=6.438*10^(-9);
C3=3.183*10^(-12);
L4=6.438*10^(-9);
C5=0.984*10^(-12);
S21=[];
S11=[];
F=[];
z=50;
for f=1:10^7:7*10^9
    w=2*pi*f;
    mat1=[1 0;j*w*C1 1];
    mat2=[1 j*w*L2;0 1];
    mat3=[1 0;j*w*C3 1];
    mat4=[1 j*w*L4;0 1];
    mat5=[1 0;j*w*C5 1];
    matf=mat1*mat2*mat3*mat4*mat5;
    a=matf(1,1);
    b=matf(1,2);
    c=matf(2,1);
    d=matf(2,2);
    S21=[S21 ; 2/(a+b/z+c*z+d)];
    S11=[S11 ; (a+b/z-c*z-d)/(a+b/z+c*z+d)];
    F=[F ;f];
end
subplot(2,1,1);
plot(F,abs(S21),'r',F,abs(S11),'g');
subplot(2,1,2);
plot(F,phase(S21),'r',F,phase(S11),'g');

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();
}

LUDO Game


#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<stdlib.h>

/* MOUSE FUNCTIONS FOR LUDO GAME */
int DetectMouse(void);
void InitMouse(void);
void ShowMouse(void);
void HideMouse(void);
void WhereMouse(int*,int*);
int ButtClicked(void);
int ButtReleased(void);

int DetectMouse(void)
{
union REGS in,out;
in.x.ax=0;
int86(0x33,&in,&out);
if(out.x.ax==0)
return(0);
else
return(1);
}


void InitMouse(void)
{
union REGS in,out;
in.x.ax=33;
int86(0x33,&in,&out);
return;
}

void HideMouse(void)
{
union REGS in,out;
in.x.ax=2;
int86(0x33,&in,&out);
return;
}

void ShowMouse(void)
{
union REGS in,out;
in.x.ax=1;
int86(0x33,&in,&out);
return;
}

void WhereMouse(int *x,int *y)
{
union REGS in,out;
in.x.ax=3;
int86(0x33,&in,&out);
*x=(int)out.x.cx;
*y=(int)out.x.dx;
return;
}

int ButtClicked(void)
{
union REGS imouse,omouse;
int mc,mr;
imouse.x.ax = 3;
int86(0x33,&imouse,&omouse);
mc=omouse.x.bx;
return(mc);
}

int ButtReleased(void)
{
int br;
br=ButtClicked();
do{}while(ButtClicked()!=0);
return br;
}

/* GLOBAL VARIABLES */
int background=0;
int colorfortext=WHITE;//color used to display text
int rec=MAGENTA;//color for border of rectangles
int flagturn;//players turn=0 computer=1
int for6=0;//for 6 to come at regular intervals
int dice_value_color[4];

/* USER DEFINED FUNCTIONS */
void draw_all(void);
int player_chooses_house_color(void);
void draw_house(int color_of_house,int top_left_x_coordinate,int
top_left_y_coordinate);
void draw_button_with_button_name(int top_left_x_coordinate,int
top_left_y_coordinate,char* button_name);
void show_mouse_click_on_button(int mouse_click_x_coordinate,int
mouse_click_y_coordinate);
int check_if_mouse_click_is_on_any_button (int mouse_click_x_coordinate,int mouse_click_y_coordinate);
void throw1(int x_coordinate_for_dice ,int y_coordinate_for_dice,int counter_for_wait_at_last ,char dice_value);
void throw2(int x_coordinate_for_dice ,int y_coordinate_for_dice,char dice_value);
int throwdice(void);
void messageout(char *message,int refresh_message=1);
void messageclear(void);
void initialise_house_with_ludos(int color_of_house);
void load_path_information_in_ludos(int ludo_house_color);
void winner(void);
void about(void);
void howtoplay(void);
void redrawing(int );
int catchclickonludobutton(void) ;
int forcomputer1(int);
int forcomputer2(int);
int forcomputer3(int);

struct ludo{
int x[45];
int y[45];
int pos;
int color;
void (*ptr_ludo1)(int,int*,int*,ludo *);
int (*ptr_check_if_ludo_move_requested_is_valid)(int ,ludo*);
void (*ptr_move_ludo_to_new_position)( int ,ludo*);
};

struct ludo lp[4],lc1[4],lc2[4],lc3[4];

/* ludo1 initialises the ludo class objects */

void ludo1(int col,int *ax,int *ay,ludo *node)
{
int i;
for(i=0;i<=44;i++)
{
node->x[i]=*(ax);
node->y[i]=*(ay);
ax++;ay++;
}
node->color=col;
node->pos=0;
}//end of ludo1

int check_if_ludo_move_requested_is_valid(int dice,ludo *node)
{
/*return 1 move valid i.e proceed to movetopos,0 if not valid
2 if player cannot move any ludo*/
int i,j=0;
if( (node->pos<=44-dice && node->pos!=0) || (node->pos==0 && dice==6))
return(1); // ludo can move
for(i=0;i<=3;i++)
{
if( (lp[i].pos+dice<=44 && lp[i].pos!=0) || (lp[i].pos==0 && dice==6) )
j=1;//i.e there is atleast one ludo which
//can move with current dice value
}
if(j>0)
return(2);//choose the correct ludo that can move
else
return(3);//no ludo can move at current dice value
//and player has to skip chance
}//end of check_if_ludo_move_requested_is_valid

void move_ludo_to_new_position( int dice ,ludo *node)
{
HideMouse();
if(node->pos==0 && dice==6)//taking out of house on dice givig 6
{ messageclear();dice=1;}
dice=dice-1;
int opos;
opos=node->pos;
int i;
for(i=opos;i<=dice+opos;i++)
{
setcolor(7);
circle(node->x[i],node->y[i],8);
setfillstyle(1,7);
floodfill(node->x[i],node->y[i],7);
delay(50);
{node->pos++; redrawing(node->color);}
setcolor(node->color);
circle(node->x[i+1],node->y[i+1],8);
setfillstyle(1,node->color);
floodfill(node->x[i+1],node->y[i+1],node->color);
delay(50);
}
/*changing pos to 0 if ludo has been cut before redrawing all ludos*/
for(i=0;i<=3;i++)
{
if(node->x[node->pos]==lp[i].x[lp[i].pos] &&
node->y[node->pos]==lp[i].y[lp[i].pos] )
{
if(node->color!=lp[i].color)
lp[i].pos=0;
}
if(node->x[node->pos]==lc1[i].x[lc1[i].pos] &&
node->y[node->pos]==lc1[i].y[lc1[i].pos] )
{
if(node->color!=lc1[i].color)
lc1[i].pos=0;
}
if(node->x[node->pos]==lc2[i].x[lc2[i].pos] &&
node->y[node->pos]==lc2[i].y[lc2[i].pos] )
{
if(node->color!=lc2[i].color)
lc2[i].pos=0;
}
if(node->x[node->pos]==lc3[i].x[lc3[i].pos] &&
node->y[node->pos]==lc3[i].y[lc3[i].pos] )
{
if(node->color!=lc3[i].color)
lc3[i].pos=0;
}
}// end of for
/* redrawing new positions of all ludos */
redrawing(lp[0].color);
redrawing(lc1[0].color);
redrawing(lc2[0].color);
redrawing(lc3[0].color);
/* to check who is the winner */
static int number_of_player_ludo_home=0;
static int number_of_computer1_ludo_home=0;
static int number_of_computer2_ludo_home=0;
static int number_of_computer3_ludo_home=0;

if(node->pos==44 && flagturn==0)
number_of_player_ludo_home++;
if(node->pos==44 && flagturn==1)
number_of_computer1_ludo_home++;
if(node->pos==44 && flagturn==2)
number_of_computer2_ludo_home++;
if(node->pos==44 && flagturn==3)
number_of_computer3_ludo_home++;
if(number_of_player_ludo_home==4)
winner();
if(number_of_computer1_ludo_home==4)
winner();
if(number_of_computer2_ludo_home==4)
winner();
if(number_of_computer3_ludo_home==4)
winner();
ShowMouse();
} //end of move_ludo_to_new_position
//end of ludo class
//struct ludo lp[4],lc1[4],lc2[4],lc3[4];

void changingcpptoc(void)
{
//struct ludo lp[4],lc1[4],lc2[4],lc3[4];
int zx;
for( zx=0;zx<4;zx++)
{
lp[zx].ptr_ludo1=ludo1;
lc1[zx].ptr_ludo1=ludo1;
lc2[zx].ptr_ludo1=ludo1;
lc3[zx].ptr_ludo1=ludo1;

lp[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_requested_is_valid;
lc1[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_requested_is_valid;
lc2[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_requested_is_valid;
lc3[zx].ptr_check_if_ludo_move_requested_is_valid=check_if_ludo_move_requested_is_valid;
lp[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position;
lc1[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position;
lc2[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position;
lc3[zx].ptr_move_ludo_to_new_position=move_ludo_to_new_position;
//int (*ptr_check_if_ludo_move_requested_is_valid)(int );
//void (*ptr_move_ludo_to_new_position)( int );
}//for zx loop ends
}
void main()
{
changingcpptoc();
int colors[4]={RED,BLUE,YELLOW,GREEN};
int i,a,b,dice=0,playercolor;;
draw_all();
InitMouse();
ShowMouse();
playercolor=player_chooses_house_color();
flagturn=0;
dice_value_color[flagturn]=playercolor;
load_path_information_in_ludos(playercolor);

//gives life to correct color ludo as path depends on color
/* this code helps in making the chance of throwing dice go in a
clockwise
mode what color may the player choose to play*/
i=3;
while(i)
{
if(colors[i]==playercolor)
break;
i--;
}

int loop=i;
while(1)
{
flagturn++;
loop++;
if(loop>=4)
loop=0;
load_path_information_in_ludos(colors[loop]);
dice_value_color[flagturn]=colors[loop];
if(flagturn==3)
break;
}

initialise_house_with_ludos(RED);
initialise_house_with_ludos(BLUE);
initialise_house_with_ludos(YELLOW);
initialise_house_with_ludos(GREEN);

flagturn=0;

char ch;
int check,tmp1=0,tmp2;
enum choose {yes,nomore};
choose choose1=yes;
delay(500);
messageclear();

while(ch!=27)
{
if(kbhit())
ch=getch();
setcolor(RED);
WhereMouse(&a,&b);
if(ButtReleased())
{
check=check_if_mouse_click_is_on_any_button(a,b);
if(check>=1 && check<=4)
show_mouse_click_on_button(a,b);
switch(check)
{
case 1:
{about();break;}
case 4:
{howtoplay(); break;}
case 3:
{exit(0);break;}
case 2:
{dice=throwdice(); break;}
} //end of switch
} //end of if(ButtRelease)

/* players chance*/
if(flagturn==0)
{
messageout("PLAYER throwdice.best of luck. ",0);
if(dice!=0)
{
if(dice==6)
messageout("click on ludo button to take out of house or move");
else
messageout("click on the ludo button to move");
while(choose1==yes)
{
choose1=nomore;
tmp1=catchclickonludobutton();
tmp2=lp[tmp1].ptr_check_if_ludo_move_requested_is_valid(dice,&lp[tmp1]);
switch(tmp2)
{
case 1:
{
lp[tmp1].ptr_move_ludo_to_new_position(dice,&lp[tmp1]);
messageout("proceeding");
delay(1000);
break;
}
case 2:
{
messageout("choose correct ludo to proceed");
delay(1000);
choose1=yes;
break;
}
case 3:
{
messageout("sorry,you will have to skip this time");
delay(1000);
break;
}
}//switch ends
}//end of while(choose1=yes)
flagturn=1;
choose1=yes;
}//end of if(dice!=0)
dice=0;
}// end of if(flagturn==0)

/*computer1 chance*/
if(flagturn==1)
{
messageout("now the computer1 will throw dice");
dice=throwdice();
if(dice!=0)
{
tmp1=forcomputer1(dice);
if(tmp1!=5)//forcomputer(dice) returns 5 if no ludo can move
lc1[tmp1].ptr_move_ludo_to_new_position(dice,&lc1[tmp1]);
else
messageout("computer1 has to skip this time.");
}
flagturn=2;
messageclear();
dice=0;
}
/*computer2 chance*/
if(flagturn==2)
{
messageout("now the computer2 will throw dice");
dice=throwdice();
if(dice!=0)
{
tmp1=forcomputer2(dice);
if(tmp1!=5)//forcomputer(dice) returns 5 if no ludo can move
lc2[tmp1].ptr_move_ludo_to_new_position(dice,&lc2[tmp1]);
else
messageout("computer2 has to skip this time.");
}
flagturn=3;
messageclear();
dice=0;
}
/*computer3 chance*/
if(flagturn==3)
{
messageout("now the computer3 will throw dice");
dice=throwdice();
if(dice!=0)
{
tmp1=forcomputer3(dice);
if(tmp1!=5)//forcomputer(dice) returns 5 if no ludo can move
lc3[tmp1].ptr_move_ludo_to_new_position(dice,&lc3[tmp1]);
else
messageout("computer3 has to skip this time.");
}
flagturn=0;
messageclear();
dice=0;
}
dice=0;
}//end of while
}//end of main

void draw_house(int col,int x,int y)
{
setcolor(rec);
rectangle(x,y,x+120,y+120);
setfillstyle(1,col);
floodfill(x+10,y+10,rec);
circle(x+30,y+30,10);
setfillstyle(1,WHITE);
floodfill(x+30,y+30,rec);
circle(x+30,y+70,10);
setfillstyle(1,WHITE);
floodfill(x+30,y+70,rec);
circle(x+90,y+30,10);
setfillstyle(1,WHITE);
floodfill(x+90,y+30,rec);
circle(x+90,y+70,10);
setfillstyle(1,WHITE);
floodfill(x+90,y+70,rec);
}

void draw_button_with_button_name(int x,int y,char *message)
{
setcolor(rec);
rectangle(x,y,x+110,y+30);
setcolor(colorfortext);
outtextxy(x+20,y+15,message);
}

void show_mouse_click_on_button(int x,int y)
{
HideMouse();
setfillstyle(1,7);
floodfill(x,y,rec);
delay(50);
setfillstyle(1,0);
floodfill(x,y,rec);
draw_button_with_button_name(0,55,"about");
draw_button_with_button_name(120,55,"exit");
draw_button_with_button_name(0,55+35,"throw dice");
draw_button_with_button_name(120,55+35,"how to play");
ShowMouse();
}

int check_if_mouse_click_is_on_any_button (int a,int b)
{
if(a>0 && a<110 && b>55 && b<85)
return 1;
else if(a>0 && a<110 && b>90 && b<120)
return 2;
else if(a>120 && a< 230 && b>55 && b<85)
return 3;
else if(a>120 && a< 230 && b>90 && b<120)
return 4;
else if(a>239 && a<359 && b>0 && b<120 )
return 5;
else if(a>239 && a<359 && b>280 && b<400 )
return 6;
else if(a>519 && a<639 && b>0 && b<120 )
return 7;
else if(a>519 && a<659 && b>280 && b<400 )
return 8;
else
return 0;
}

int throwdice()
{
HideMouse();
int rn,count=0;char num;
int x=0,y,flag=0;
randomize();
for(y=150;y<=320;y=y+10,x=x+10)
{
rn=random(6)+1;
/* using for6 to get a 6 on dice every 5th time to make the game a
little faster*/
if(y==320)
{for6++;}
if(for6>=5)
{
rn=6;
for6=0;
}
// cout<<for6;
//if(y==320)
// for6++;
num=rn+48;
if(flag==0)
{
throw2(x,y,num);
flag=1;
}
else
{
count++;
throw1(x,y,count,num);
flag=0;
}
}
settextstyle(0,0,0);
ShowMouse();
return rn;
}

void throw1(int x,int y,int count,char num)
{
settextstyle(0,0,3);
setcolor(WHITE);
rectangle(x,y,x+35,y+35);
//setcolor(RED);
setcolor(dice_value_color[flagturn]);
outtextxy(x+5,y+5,&num);
delay(140);
if(count==9)
{delay(650); }
setcolor(0);
rectangle(x,y,x+35,y+35);
outtextxy(x+5,y+5,&num);
}
void throw2(int x,int y,char num)
{
x=x-17;y=y+10;
settextstyle(0,0,3);
setcolor(WHITE);
line(x,y,x+25,y+25);
line(x,y,x+25,y-25);
line(x+25,y+25,x+50,y);
line(x+25,y-25,x+50,y);
//setcolor(RED);
setcolor(dice_value_color[flagturn]);
outtextxy(x+15,y-10,&num);
delay(140);
setcolor(0);
line(x,y,x+25,y+25);
line(x,y,x+25,y-25);
line(x+25,y+25,x+50,y);
line(x+25,y-25,x+50,y);
outtextxy(x+15,y-10,&num);
}
void messageout(char *message,int refresh)
{
if(refresh)
messageclear();
setcolor(colorfortext);
outtextxy(20,450,message);
}
void messageclear()
{
HideMouse();
setfillstyle(1,0);
floodfill(20,450,rec);
ShowMouse();
}

void initialise_house_with_ludos(int color)
{
int x,y;
switch(color)
{
case RED:
{x=239;y=0;break;}
case BLUE:
{x=519;y=0;break;}
case YELLOW:
{x=639-120;y=280;break;}
case GREEN:
{x=239;y=280;break;}
}
draw_house(color,x,y);
setcolor(rec);
setfillstyle(1,color);
{
circle(x+30,y+30,8);
floodfill(x+30,y+30,rec);
}
{
circle(x+30,y+70,8);
floodfill(x+30,y+70,rec);
}
{
circle(x+90,y+30,8);
floodfill(x+90,y+30,rec);
}
{
circle(x+90,y+70,8);
floodfill(x+90,y+70,rec);
}
}
void load_path_information_in_ludos(int plcol)
{
int arx[45],ary[45];
switch(plcol)
{
case RED:
{ int
arx[45]={269,284,314,344,379,379,379,379,379,439,499,499, 499,
499,499,534,564,594,624,624,624,594,564,534,499,
499,499,499,499,439,384,384,384,384,384,344,314,284,254,254,284,314,344,384,424};
int
ary[45]={30,140,140,140,140,105,75,45,15,15,15,45,75,105, 140,140,
140,140,140,200,260,260,260,260,260,295,325,355,385,385,385,355,325,295,260,260,260,260,260,200,200,200,200,200,
200};

for(int tmp=0;tmp<=3;tmp++)
{
switch(tmp)
{
case 0: {arx[0]=269;ary[0]=30;break;}
case 1: {arx[0]=329;ary[0]=70;break;}
case 2: {arx[0]=329;ary[0]=30;break;}
case 3: {arx[0]=269;ary[0]=70;break;}
}
switch(flagturn)
{
case 0:
{lp[tmp].ptr_ludo1(RED,arx,ary,&lp[tmp]);break;}
case 1:
{lc1[tmp].ptr_ludo1(RED,arx,ary,&lc1[tmp]);break;}
case 2:
{lc2[tmp].ptr_ludo1(RED,arx,ary,&lc2[tmp]);break;}
case 3:
{lc3[tmp].ptr_ludo1(RED,arx,ary,&lc3[tmp]);break;}
}
}
break;}//case RED ends
case BLUE:
{ int
arx[45]={549,499,499,499,499,534,564,594,624,624,624,594, 564,
534,499,499,499,499,499,439,384,384,384,384,384,344,
314,284,254,254,254,284,314,344,379,379,379,379,379,
439,439,439,439,439,439 };
int ary[45]={30,45,75,105,140,140,140,140,140,200,260,260,260 ,260,
260,295,325,355,385,385,385,355,325,295,260,260,260,
260,260,200,140,140,140,140,140,105,75,45,15,15,45,75,105,140,185};
for(int tmp=0;tmp<=3;tmp++)
{
switch(tmp)
{
case 0: {arx[0]=549;ary[0]=30;break;}
case 1: {arx[0]=549;ary[0]=70;break;}
case 2: {arx[0]=609;ary[0]=30;break;}
case 3: {arx[0]=609;ary[0]=70;break;}
}
switch(flagturn)
{
case 0:
{lp[tmp].ptr_ludo1(BLUE,arx,ary,&lp[tmp]);break;}
case 1:
{lc1[tmp].ptr_ludo1(BLUE,arx,ary,&lc1[tmp]);break;}
case 2:
{lc2[tmp].ptr_ludo1(BLUE,arx,ary,&lc2[tmp]);break;}
case 3:
{lc3[tmp].ptr_ludo1(BLUE,arx,ary,&lc3[tmp]);break;}
}
}
break;}
case GREEN:
{ int
arx[45]={269,384,384,384,384,344,314,284,254,254,254,284, 314,
344,379,379,379,379,379,439,499,499,499,499,499,534,
564,594,624,624,624,594,564,534,499,499,499,499,499,
439,439,439,439,439,439 };
int ary[45]={30,355,325,295,260,260,260,
260,260,200,140,140,140,140,140,105,75,45,15,15,15,45
,75,105,140,140,140,140,140,200,260,260,260,260,
260,295,325,355,385,385,355,325,295,260,215};
for(int tmp=0;tmp<=3;tmp++)
{
switch(tmp)
{
case 0: {arx[0]=269;ary[0]=310;break;}
case 1: {arx[0]=329;ary[0]=350;break;}
case 2: {arx[0]=329;ary[0]=310;break;}
case 3: {arx[0]=269;ary[0]=350;break;}
}
switch(flagturn)
{
case 0:
{lp[tmp].ptr_ludo1(GREEN,arx,ary,&lp[tmp]);break;}
case 1:
{lc1[tmp].ptr_ludo1(GREEN,arx,ary,&lc1[tmp]);break;}
case 2:
{lc2[tmp].ptr_ludo1(GREEN,arx,ary,&lc2[tmp]);break;}
case 3:
{lc3[tmp].ptr_ludo1(GREEN,arx,ary,&lc3[tmp]);break;}
}
}
break;}
case YELLOW:
{ int
arx[45]={549,594,564,534,499,499,499,499,499,439,384,384, 384,
384,384,344,314,284,254,254,254,284,314,344,379,379,
379,379,379,439,499,499,499,499,499,534,564,594,624,
624,594,564,534,499,454};
int
ary[45]={310,260,260,260,260,295,325,355,385,385,385,355, 325,295,
260,260,260,260,260,200,140,140,140,140,140,105,75,45,15,
15,15,45,75,105,140,140,140,140,140,200,200,200,200,200,200};
for(int tmp=0;tmp<=3;tmp++)
{
switch(tmp)
{
case 0: {arx[0]=549;ary[0]=310;break;}
case 1: {arx[0]=549;ary[0]=350;break;}
case 2: {arx[0]=609;ary[0]=310;break;}
case 3: {arx[0]=609;ary[0]=350;break;}
}
switch(flagturn)
{
case 0:
{lp[tmp].ptr_ludo1(YELLOW,arx,ary,&lp[tmp]);break;}
case 1:
{lc1[tmp].ptr_ludo1(YELLOW,arx,ary,&lc1[tmp]);break;}
case 2:
{lc2[tmp].ptr_ludo1(YELLOW,arx,ary,&lc2[tmp]);break;}
case 3:
{lc3[tmp].ptr_ludo1(YELLOW,arx,ary,&lc3[tmp]);break;}
}
}
break;}
}//switch ends
}
int catchclickonludobutton()
{
int a,b,i;
while(1)
{
WhereMouse(&a,&b);
if(ButtReleased())
{ for(i=0;i<=3;i++)
{
if( abs(a-(lp[i].x[lp[i].pos])) < 8 &&
abs(b-(lp[i].y[lp[i].pos])) <
8 )
return i;
}
}
}
}
void redrawing(int tmp)
{
int i;
for(i=0;i<=3;i++)
{
if(tmp==lp[0].color)
{
setcolor(lp[i].color);
circle(lp[i].x[lp[i].pos],lp[i].y[lp[i].pos],8);
setfillstyle(1,lp[i].color);
floodfill(lp[i].x[lp[i].pos],lp[i].y[lp[i].pos],lp[i].color);
}
if(tmp==lc1[0].color)
{
setcolor(lc1[i].color);
circle(lc1[i].x[lc1[i].pos],lc1[i].y[lc1[i].pos],8);
setfillstyle(1,lc1[i].color);
floodfill(lc1[i].x[lc1[i].pos],lc1[i].y[lc1[i].pos],lc1[i].color);
}
if(tmp==lc2[0].color)
{
setcolor(lc2[i].color);
circle(lc2[i].x[lc2[i].pos],lc2[i].y[lc2[i].pos],8);
setfillstyle(1,lc2[i].color);
floodfill(lc2[i].x[lc2[i].pos],lc2[i].y[lc2[i].pos],lc2[i].color);
}
if(tmp==lc3[0].color)
{
setcolor(lc3[i].color);
circle(lc3[i].x[lc3[i].pos],lc3[i].y[lc3[i].pos],8);
setfillstyle(1,lc3[i].color);
floodfill(lc3[i].x[lc3[i].pos],lc3[i].y[lc3[i].pos],lc3[i].color);
}
}//for ends
}

/* deciding for computer1 which ludo to move */
int forcomputer1(int dice)
{
int i,j,tmp,poslpforlc[12]={0,0,0,0,0,0,0,0,0,0,0,0},cannotmove=5;
/* checking if atleast one ludo can move at current dice value*/
for(i=0;i<=3;i++)
{
if( (lc1[i].pos<=44-dice && lc1[i].pos!=0) || (lc1[i].pos==0 &&
dice==6) )
cannotmove=0;//cannotmove=5 then no ludo can move
}
if(cannotmove==5)
return 5;

//position of players ludo in terms of computers1 ludo positions
for(i=0;i<=3;i++)
{
for(j=1;j<=40;j++)
{
if( lc1[0].x[j]==lp[i].x[lp[i].pos] &&
lc1[0].y[j]==lp[i].y[lp[i].pos])
{
poslpforlc[i]=j;
}
}
}
//position of computer2 ludo in terms of computer1 ludo positions
for(i=4;i<=7;i++)
{
for(j=1;j<=40;j++)
{
if( lc1[0].x[j]==lc2[i-4].x[lc2[i-4].pos] &&
lc1[0].y[j]==lc2[i-4].y[lc2[i-4].pos])
{
poslpforlc[i]=j;
}
}
}
//position of computer3 ludo in terms of computer1 ludo positions
for(i=8;i<=11;i++)
{
for(j=1;j<=40;j++)
{
if( lc1[0].x[j]==lc3[i-8].x[lc3[i-8].pos] &&
lc1[0].y[j]==lc3[i-8].y[lc3[i-8].pos])
{
poslpforlc[i]=j;
}
}
}//end of i
/*to cut opponents ludo button*/
for(i=0;i<=3;i++)
{
for(j=0;j<=11;j++)
{
if( dice==(poslpforlc[j] - lc1[i].pos) && lc1[i].pos!=0)
return i;
}
}

/* to move those ludos which are near the player ludos and have the
gretest value of pos i.e position . it means saving the threatened
ludo*/
int array[4]={0,0,0,0};
int a1=0,tmp1;
for(i=0;i<=3;i++)
{
for(j=0;j<=11;j++)
{
if( (-poslpforlc[j] + lc1[i].pos)<=6
&& (-poslpforlc[j] + lc1[i].pos)>=1
&& lc1[i].pos+dice<=44
&& poslpforlc[j]!=0
&& lc1[i].pos<=40 )
{array[i]=lc1[i].pos;}
}
if(a1<=array[i])
a1=array[i];/* a1 has the greatest pos value */
}
if(a1!=0) //to see that at least one ludo is threatened */
{
for(i=0;i<=3;i++) //getting the ludo with greatest pos value
{
if(a1==array[i])
return i;
}
}
//to take out ludo button from house
for(i=0;i<=3;i++)
{
if(dice==6)
{
if(lc1[i].pos==0 )
return i;
}
}
/*if ludo buttons are outside and option for cutting opponent or
taking
out
own ludo button are not valid , using round robin
for selecting ludo to move*/
static int ludolast=0;
int firstround=0;
for(i=0;i<=3;i++)
{
if(firstround==0)
{
if(ludolast!=3)
{i=ludolast+1;}
firstround++;
}
if(lc1[i].pos!=0 && lc1[i].pos+dice<=44 )
{ludolast=i;i=4;}
if(i==3)
i=-1;
}
return ludolast;
//if ludo button is
}

/* deciding for computer2 which ludo to move */
int forcomputer2(int dice)
{
int i,j,tmp,poslpforlc[12]={0,0,0,0,0,0,0,0,0,0,0,0},cannotmove=5;
/* checking if atleast one ludo can move at current dice value*/
for(i=0;i<=3;i++)
{
if( (lc2[i].pos<=44-dice && lc2[i].pos!=0) || (lc2[i].pos==0 &&
dice==6) )
cannotmove=0;//cannotmove=5 then no ludo can move
}
if(cannotmove==5)
return 5;

//position of players ludo in terms of computers2 ludo positions
for(i=0;i<=3;i++)
{
for(j=1;j<=40;j++)
{
if( lc2[0].x[j]==lp[i].x[lp[i].pos] &&
lc2[0].y[j]==lp[i].y[lp[i].pos])
{
poslpforlc[i]=j;
}
}
}
//position of computer1 ludo in terms of computer2 ludo positions
for(i=4;i<=7;i++)
{
for(j=1;j<=40;j++)
{
if( lc2[0].x[j]==lc1[i-4].x[lc1[i-4].pos] &&
lc2[0].y[j]==lc1[i-4].y[lc1[i-4].pos])
{
poslpforlc[i]=j;
}
}
}
//position of computer3 ludo in terms of computer2 ludo positions
for(i=8;i<=11;i++)
{
for(j=1;j<=40;j++)
{
if( lc2[0].x[j]==lc3[i-8].x[lc3[i-8].pos] &&
lc2[0].y[j]==lc3[i-8].y[lc3[i-8].pos])
{
poslpforlc[i]=j;
}
}
}//end of i
for(i=0;i<=11;i++)
{
}
/*to cut opponents ludo button*/
for(i=0;i<=3;i++)
{
for(j=0;j<=11;j++)
{
if( dice==(poslpforlc[j] - lc2[i].pos) && lc2[i].pos!=0)
{return i;}
}
}

/* to move those ludos which are near the player ludos and have the
gretest value of pos i.e position . it means saving the threatened
ludo*/
int array[4]={0,0,0,0};
int a1=0,tmp1;
for(i=0;i<=3;i++)
{
for(j=0;j<=11;j++)
{
if( (-poslpforlc[j] + lc2[i].pos)<=6
&& (-poslpforlc[j] + lc2[i].pos)>=1
&& lc2[i].pos+dice<=44
&& poslpforlc[j]!=0
&& lc2[i].pos<=40 )
{array[i]=lc2[i].pos;}
}
if(a1<=array[i])
a1=array[i];/* a1 has the greatest pos value */
}
if(a1!=0) //to see that at least one ludo is threatened */
{
for(i=0;i<=3;i++) //getting the ludo with greatest pos value
{
if(a1==array[i])
{return i;}
}
}
//to take out ludo button from house
for(i=0;i<=3;i++)
{
if(dice==6)
{
if(lc2[i].pos==0 )
{return i;}
}
}
/*if ludo buttons are outside and option for cutting opponent or
taking
out
own ludo button are not valid , using round robin
for selecting ludo to move*/
static int ludolast=0;
int firstround=0;
for(i=0;i<=3;i++)
{
if(firstround==0)
{
if(ludolast!=3)
{i=ludolast+1;}
firstround++;
}
if(lc2[i].pos!=0 && lc2[i].pos+dice<=44 )
{ludolast=i;i=4;}
if(i==3)
i=-1;
}
return ludolast;
//if ludo button is
}
/* deciding for computer3 which ludo to move */
int forcomputer3(int dice)
{
int i,j,tmp,poslpforlc[12]={0,0,0,0,0,0,0,0,0,0,0,0},cannotmove=5;
/* checking if atleast one ludo can move at current dice value*/
for(i=0;i<=3;i++)
{
if( (lc3[i].pos<=44-dice && lc3[i].pos!=0) || (lc3[i].pos==0 &&
dice==6) )
cannotmove=0;//cannotmove=5 then no ludo can move
}
if(cannotmove==5)
return(5);

//position of players ludo in terms of computers1 ludo positions
for(i=0;i<=3;i++)
{
for(j=1;j<=40;j++)
{
if( lc3[0].x[j]==lp[i].x[lp[i].pos] &&
lc3[0].y[j]==lp[i].y[lp[i].pos])
{
poslpforlc[i]=j;
}
}
}
//position of computer2 ludo in terms of computer3 ludo positions
for(i=4;i<=7;i++)
{
for(j=1;j<=40;j++)
{
if( lc3[0].x[j]==lc2[i-4].x[lc2[i-4].pos] &&
lc3[0].y[j]==lc2[i-4].y[lc2[i-4].pos])
{
poslpforlc[i]=j;
}
}
}
//position of computer1 ludo in terms of computer3 ludo positions
for(i=8;i<=11;i++)
{
for(j=1;j<=40;j++)
{
if( lc3[0].x[j]==lc1[i-8].x[lc1[i-8].pos] &&
lc3[0].y[j]==lc1[i-8].y[lc1[i-8].pos])
{
poslpforlc[i]=j;
}
}
}//end of i
/*to cut opponents ludo button*/
for(i=0;i<=3;i++)
{
for(j=0;j<=11;j++)
{
if( dice==(poslpforlc[j] - lc3[i].pos) && lc3[i].pos!=0 )
return i;
}
}

/* to move those ludos which are near the player ludos and have the
gretest value of pos i.e position . it means saving the threatened
ludo*/
int array[4]={0,0,0,0};
int a1=0,tmp1;
for(i=0;i<=3;i++)
{
for(j=0;j<=11;j++)
{
if( (-poslpforlc[j] + lc3[i].pos)<=6
&& (-poslpforlc[j] + lc3[i].pos)>=1
&& lc3[i].pos+dice<=44
&& lc3[i].pos<=40
&& poslpforlc[j]!=0 )
{array[i]=lc3[i].pos;}
}
if(a1<=array[i])
a1=array[i];/* a1 has the greatest pos value */
}
if(a1!=0) //to see that at least one ludo is threatened */
{
for(i=0;i<=3;i++) //getting the ludo with greatest pos value
{
if(a1==array[i])
{return i;}
}
}
//to take out ludo button from house
for(i=0;i<=3;i++)
{
if(dice==6)
{
if(lc3[i].pos==0 )
return i;
}
}
/*if ludo buttons are outside and option for cutting opponent or
taking
out
own ludo button are not valid , using round robin
for selecting ludo to move*/
static int ludolast=0;
int firstround=0;
for(i=0;i<=3;i++)
{
if(firstround==0)
{
if(ludolast!=3)
{i=ludolast+1;}
firstround++;
}
if(lc3[i].pos!=0 && lc3[i].pos+dice<=44 )
{ludolast=i;i=4;}
if(i==3)
i=-1;
}
return ludolast;
//if ludo button is
}

void draw_all()
{
//registerbgidriver(EGAVGA_driver);
//registerbgifont(sansserif_font);
int gdriver = DETECT, gmode;
/* request auto detection */
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "");
/* writing text */
setcolor(background);
settextstyle(0,0,0);
setcolor (colorfortext);
outtextxy(5,10,"(aks_mailin@rediffmail.com)");
outtextxy(5,20,"akshay presents");
outtextxy(5,30,"COMPUTER LUDO");
outtextxy(5,40,"GAME");
/* drawing rectangles */
setcolor(rec);
rectangle(0,410,639,479);
rectangle(0,0,230,50);
setcolor(rec);
rectangle(239,0,639,400);
setfillstyle(1,7);
floodfill(310,10,rec);
draw_house(RED,239,0);
draw_house(GREEN,239,280);
draw_house(BLUE,639-120,0);
draw_house(YELLOW,639-120,280);
draw_button_with_button_name(0,55,"about");
draw_button_with_button_name(120,55,"exit");
draw_button_with_button_name(0,55+35,"throw dice");
draw_button_with_button_name(120,55+35,"how to play");

/*drawing sectors*/
setcolor(0);
line(359,30,519,30 );
line(359,60,519,60 );
line(359,90,519,90 );
line(359,120,519,120 );
line(359,280,519,280);
line(359,310,519,310);
line(359,340,519,340 );
line(359,370,519,370 );
line(239,160,639,160 );
line(239,240,639,240 );
line(269,120,269,280);
line(269+30,120,269+30,280 );
line(269+60,120,269+60,280 );
line(269+90,120,269+90,280 );
line(269+130,0,269+130,400 );
line(269+210,0,269+210,400 );
line(269+250,120,269+250,280 );
line(269+280,120,269+280,280 );
line(269+310,120,269+310,280 );
line(269+340,120,269+340,280 );
setfillstyle(1,WHITE);
floodfill(439,200,background);
setcolor(RED);
outtextxy(420,190,"HOME");
return ;
}
int player_chooses_house_color(void)
{
char ch;
int check;
int a,b,playercolor=0;
messageout("PLAYER,click YOUR lucky COLOR on the board ");
while(ch!=27)
{
if(playercolor!=0)
break;//come out of while
if(kbhit())
ch=getch();
setcolor(RED);
WhereMouse(&a,&b);
if(ButtReleased())
{
check=check_if_mouse_click_is_on_any_button (a,b);
switch(check)
{
case 1:
{show_mouse_click_on_button(a,b);about();break;}
case 4:
{show_mouse_click_on_button(a,b);howtoplay(); break;}
case 3:
{show_mouse_click_on_button(a,b);exit(0);break;}
case 5:
{ messageout( "you have choosen red");
playercolor=RED;
break;}
case 6:
{ messageout( "you have choosen green");
playercolor=GREEN;
break;}
case 7:
{ messageout( "you have choosen blue");
playercolor=BLUE;
break;}
case 8:
{ messageout( "you have choosen yellow");
playercolor=YELLOW;
break;}
} //end of switch
}//end of if(ButtRelease)
}//end of while
delay(500);
return playercolor;
}
void about(void)
{
HideMouse();
setcolor(rec);
rectangle(0,135,230,390);
setcolor(colorfortext);
outtextxy(5,150,"WELCOME to ComputerLudo");
outtextxy(5,160,"This software is developed");
outtextxy(5,170,"by");
outtextxy(5,180,"");
outtextxy(5,190,"");
outtextxy(5,210,"Akshay ");
outtextxy(5,230,"U can send suggestions at");
outtextxy(5,240,"my Email:");
outtextxy(5,250,"aks_mailin@rediffmail.com");
outtextxy(5,260,"thanks");
outtextxy(5,310,"PRESS ANY KEY TO PROCEED ...");
getch();
setfillstyle(1,0);
floodfill(5,300,rec);
setcolor(0);
rectangle(0,135,230,390);
setcolor(rec);
ShowMouse();
return ;
}
void winner()
{
HideMouse();
setcolor(rec);
rectangle(0,135,230,390);
setcolor(colorfortext);
outtextxy(5,150,"welcome to ComputerLudo");
if(flagturn==0)
{
outtextxy(5,160,"CONGRATULATIONS");
outtextxy(5,170,"YOU WON THIS ROUND ");
outtextxy(5,180,"OF");
outtextxy(5,190,"ComputerLudo");
outtextxy(5,210,"akshay thanks ");
outtextxy(5,220,"you for trying this");
outtextxy(5,230,"game.");
outtextxy(5,240,"thanks again.");
outtextxy(5,310,"PRESS ANY KEY TO EXIT..");
}
else
{
switch(flagturn)
{
case 1:
{outtextxy(5,160,"COMPUTER1 WON THIS");break;}
case 2:
{outtextxy(5,160,"COMPUTER2 WON THIS");break;}
case 3:
{outtextxy(5,160,"COMPUTER3 WON THIS");break;}
}
outtextxy(5,170,"ROUND OF");
outtextxy(5,180,"ComputerLudo");
outtextxy(5,200,"BETTER LUCK NEXT TIME");
outtextxy(5,220,"akshay thanks ");
outtextxy(5,230,"you for trying this");
outtextxy(5,240,"game.");
outtextxy(5,250,"thanks again.");
outtextxy(5,310,"PRESS ANY KEY TO EXIT..");
}
getch();
exit(0);
}


void howtoplay()
{
HideMouse();
setcolor(rec);
rectangle(0,135,230,390);
setcolor(colorfortext);
outtextxy(5,150,"This is a game between");
outtextxy(5,160,"COMPUTER and the PLAYER.");
outtextxy(5,170,"Choose HOUSE by ");
outtextxy(5,180,"clicking over the HOUSE of");
outtextxy(5,190,"your fovourite color.");
outtextxy(5,200,"Get 6 on Dice to take a ludo");
outtextxy(5,210,"out of HOUSE.To make a ludo");
outtextxy(5,220,"MOVE click on it.");
outtextxy(5,230,"CUT(send to house) computers");
outtextxy(5,240,"ludos by placing your ludos ");
outtextxy(5,250,"over its ludos.");
outtextxy(5,260,"One who gets all the ludos");
outtextxy(5,270,"HOME wins thE Game.");
outtextxy(5,290,"FOLLOW THE MESSAGE BOX");
outtextxy(5,300,"GIVEN AT BOTTOM");
outtextxy(5,320,"thanks");
outtextxy(2,330,"Akshay.");
outtextxy(5,350,"PRESS ANY KEY TO PROCEED ...");
getch();
setfillstyle(1,0);
floodfill(5,300,rec);
setcolor(0);
rectangle(0,135,230,390);
setcolor(rec);
ShowMouse();
return ;
}

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<<"";
}
}