Ejemplo n.º 1
0
//---------------------------------------------------------------
void main()
{
   int i,j;
   clrscr();

   for(i=0;i<9;i++)     // flush all the arrays
      for(j=0;j<9;j++)
	 cnt = arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0;

   int gd=DETECT,gm;
   initgraph(&gd, &gm,path);

   if(LOAD)  loading();

   clrscr();
   initgraph(&gd, &gm,path);

   setbkcolor(BLACK);
   rectangle(0,27,637,477);
   setfillstyle(1,BLUE);
   floodfill(25,30,15);
   frame(20,100,90,460,LIGHTRED,RED,GREEN);

   _1.draw();   _4.draw();   _7.draw();
   _2.draw();   _5.draw();   _8.draw();
   _3.draw();   _6.draw();   _9.draw();
   _ER.draw();

   ext_button();
   menubar();
   maze();
   fill_maze();
   Control();
}
Ejemplo n.º 2
0
void fill_maze(int x, int y, int lenght = 0)
{
  cell& cur = maze[x][y];
  cur.visited = true;
  if(lenght > endlen)
  {
    endx = x;
    endy = y;
    endlen = lenght;
  }
  for(int i = 0; i < 30; i++) // all directions in random order
  {
    direction dir = random_dir();
    int cx = x, cy = y; // neightbor
    if(!offset(dir, cx, cy))
      continue;
    cell& n = maze[cx][cy];
    if(n.visited)
      continue;
    
    // make path
    cur.break_wall(dir);
    n.break_wall(opposite(dir));
    
    
    // recursion
    fill_maze(cx, cy, lenght + 1);
  }
}
Ejemplo n.º 3
0
int main()
{
  srand(time(0));
  
  // start(end) point 
  
  int startx = rand() % SIZE_X;
  int starty = rand() % SIZE_Y;
  fill_maze(startx, starty);
  // maze is filled
  std::cout << endlen << std::endl;
  
  char buffer[SIZE_Y * 3][SIZE_X * 3 + 1]; // each cell is 3x3 tiles
  for(int y = 0; y < SIZE_Y; y++)
  {
    int by = y * 3;
    for(int x = 0; x < SIZE_X; x++)
    {
      int bx = x * 3;
      
      cell& cur = maze[x][y];
      
      // fill corners
      /*
       * X-X
       * ---
       * X-X
       * */
      buffer[by][bx] = buffer[by+2][bx] = buffer[by][bx+2] = buffer[by+2][bx+2] = 'X';
      
      // fill walls
      buffer[by][bx+1] =  cur.has_wall(up) ? 'O' : RAND_FREEZE;
      buffer[by+2][bx+1] =  cur.has_wall(down) ? 'O' : RAND_FREEZE;
      buffer[by+1][bx] =  cur.has_wall(left) ? 'O' : RAND_FREEZE;
      buffer[by+1][bx+2] =  cur.has_wall(right) ? 'O' : RAND_FREEZE;
      
      // center is empty
      buffer[by+1][bx+1] = ' ';
    }
    buffer[by][SIZE_X * 3] = buffer[by+1][SIZE_X * 3] = buffer[by+2][SIZE_X * 3] = buffer[by+3][SIZE_X * 3] = '\0'; // end of line
  }
  
  for(int y = 0; y < 3; y++)
    for(int x = 0; x < 3; x++)
    {
      buffer[starty * 3 + y][startx * 3 + x] = ((y == 2) ? 's' : 'S');
      buffer[endy * 3 + y][endx * 3 + x] = 'e';
    }
  //buffer[endy * 3 + 1][endx * 3 + 1] = 'e';
  
  // output
  
  std::ofstream out("maze.txt");
  out << SIZE_X * 3 << ' ' << SIZE_Y * 3 << '\n';
  for(int y = 0; y < SIZE_Y * 3; y++)
    out << buffer[y] << '\n';
  
  return 0;
}
Ejemplo n.º 4
0
int main()
{
  srand(time(0));
  //srand(0);
  
  // start(end) point 
  
  int startx = rand() % SIZE_X;
  int starty = 0;
  fill_maze(startx, starty);
  // maze is filled
  std::cout << endlen << std::endl; // finish, not start !
  
  // output
  
  std::ofstream out("maze.txt");
  out << SIZE_X * CELL_X << ' ' << SIZE_Y * CELL_Y << '\n';
  
  for(int y = 0; y < SIZE_Y; y++)
  {
    for(int row = 0; row < CELL_Y; row++)
    {
      char row_buf[CELL_X+1];
      row_buf[CELL_X] = '\0';
      for(int x = 0; x < SIZE_X; x++)
      {
        cell& cur = maze[x][y];
        if(x == startx && y == starty)
          fill_special_row(row_buf, row, ' ', ' ', 'e');
        else if(x == endx && y == endy)
          fill_special_row(row_buf, row, 'S', 's', 'h');
        else
        {
          cur.fill_row(row_buf, row);
        }
        
        out << row_buf;
      }
      
      out << '\n';
    }
    //out << '\n';
  }
  
  //for(int i = 0; i < SIZE_X * CELL_X; i++)
    //out << '.';
  //out << '\n';
  
  return 0;
}
Ejemplo n.º 5
0
//---------------------------------------------------------------
void Usr_Submit(void)
{
   if(cnt < 81)  // fill all positions and then try
   {
	frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	frame(196,186,424,200,BLUE,BLUE,BLUE);
	setcolor(WHITE);
	settextstyle(0,0,1);
	outtextxy(280,190,"MESSAGE");
	setcolor(BLACK);
	outtextxy(203,216,"FILL ALL POSITIONS AND");
	outtextxy(203,231,"THEN TRY !");
	delay(1000);
	Message_Box();
   }

   else //if(cnt == 81)
   {
      int flag = 0;

      for(int i=0;i<9;i++)
	for(int j=0;j<9;j++)
	{
	  if(arr[i][j] != puzz[i][j])
	  {   flag = 1;
	      break;
	  }
	}

       if(flag == 1)
       {
	frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	frame(196,186,424,200,BLUE,BLUE,BLUE);
	setcolor(WHITE);
	settextstyle(0,0,1);
	outtextxy(280,190,"MESSAGE");
	setcolor(BLACK);
	outtextxy(203,230,"YOUR SOLUTION IS WRONG.");
	outtextxy(203,246,"DO TRY !");
	delay(1000);
	Message_Box();
	cnt = 81;
       }

       else
       {
	frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	frame(196,186,424,200,BLUE,BLUE,BLUE);
	setcolor(WHITE);
	settextstyle(0,0,1);
	outtextxy(280,190,"MESSAGE");
	setcolor(BLACK);
	outtextxy(203,230,"CONGRATULATIONS !! ");
	outtextxy(203,246,"YOU HAVE CRACKED THIS ONE.");
	delay(1000);
	Message_Box();
	for(i=0;i<9;i++)     // flush all the arrays
	  for(j=0;j<9;j++)
	    cnt = arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0;

	maze();
	fill_maze();
	men_stat = 0;
	code = -1;
	puz_typ = 0;
	Number_Pad(9);
	curr=10;
       }
   }
}
Ejemplo n.º 6
0
//---------------------------------------------------------------
void wait_mouse()
{
   // quit via menu
   if(code==44)
   {
      if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280)
      {
	frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(240,265,"YES");delay(200);
	closegraph();exit(0);
      }

      if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280)
      {
	frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(357,265,"NO");delay(200);
	code = 0;
	Message_Box();
      }
      return;
   }

   // quit via corner button
   if(o.x.cx>=613 && o.x.dx>=7 && o.x.cx<=638 && o.x.dx<=27)
   {
      code = 44; // quit
      fill_maze();
      frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
      frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
      frame(196,186,424,200,BLUE,BLUE,BLUE);
      settextstyle(0,0,1);
      setcolor(WHITE);
      outtextxy(280,190,"MESSAGE");
      setcolor(BLACK);
      outtextxy(203,216,"DO YOU REALLY WANT TO ");
      outtextxy(203,231,"EXIT ?");

      frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE);
      frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE);
      outtextxy(240,265,"YES");
      outtextxy(357,265,"NO");
      frame(5,31,260,90,BLUE,BLUE,BLUE);
      menubar();
      return;
   }
   ///////////////////////////////////////////
   if(code == 47) // load a game from file
   {
      if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280)
      {
	frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(235,265,"OPEN");
	delay(200);
	load();
	Message_Box();
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	code = 0;
	fill_maze();

	while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70)
	{
	 frame(45,31,105,70,BLUE,BLUE,BLUE);
	 showmouse();getmousepos();
	}
	menubar();
      }
      //--------------------------------------------------------
      if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280)
      {
	frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(343,265,"CANCEL");delay(200);
	code = 0;
	Message_Box();
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	menubar();
      }
      return;
   }
  ///////////////////////////////////////////
   if(code == 48) // save a game to file
   {
      if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280)
      {
	frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(245,265,"OK");
	delay(200);
	save();
	code = 0;
	Message_Box();
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	menubar();
	fill_maze();

	while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70)
	{
	 frame(45,31,105,70,BLUE,BLUE,BLUE);
	 showmouse();getmousepos();
	}
	menubar();

      }
     //--------------------------------------------------------
      if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280)
      {
	frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(343,265,"CANCEL");
	delay(200);
	code = 0;
	Message_Box();
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	menubar();
      }
      return;
   }
   ///////////////////////////////////////////
   //////////////////////////////////////////
   if(code == 42) // resign
   {
      if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280)
      {
	frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE);
	outtextxy(240,265,"YES");
	delay(200);
	Message_Box();
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	menubar();

	for(int i=0;i<9;i++)
	  for(int j=0;j<9;j++)
	   {
	      arr[i][j] = puzz[i][j];
	   }

	Message_Box();

	for( i=0;i<9;i++)
	  for( j=0;j<9;j++)
	   {
	     arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0;
	   }

	code = 0;
	puz_typ = 0;
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	frame(45,31,105,70,BLUE,BLUE,BLUE);
	menubar();
	return;
      }
    //-------------------------------------------------------------
      if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280)
      {
       frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE);
       outtextxy(357,265,"NO");
       delay(200);
       code = 0;
       Message_Box();
       frame(5,31,260,90,BLUE,BLUE,BLUE);
       menubar();
      }
      return;
   }

   if(menu_bar_effect())
   { return; }

   if( o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=85
      && men_stat == 4 && puz_typ != 0)
     {
	men_stat = 0;

	if( o.x.dx<=42   )
	{
	    if(code != 41)  // pause
	    { code = 41;fill_maze(); }

	    else if(code == 41)    // resume
	    {
	       code = 0; fill_maze();
	       while(o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=72)
	       {
		  frame(5,31,260,90,BLUE,BLUE,BLUE);
		  showmouse();
		  getmousepos();
	       }
	       menubar();
	       return;
	     }
	}

	else if( o.x.dx<=55 )   //   Resign();
	{
	    if(code != 41)  // not pause
	    {
	       code = 42;
	       fill_maze();
	       frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	       frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	       frame(196,186,424,200,BLUE,BLUE,BLUE);
	       setcolor(WHITE);
	       settextstyle(0,0,1);
	       outtextxy(280,190,"MESSAGE");
	       setcolor(BLACK);
	       outtextxy(203,216,"DO YOU REALLY WANT TO ");
	       outtextxy(203,231,"RESIGN ?");

	       frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE);
	       frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE);
	       outtextxy(240,265,"YES");
	       outtextxy(357,265,"NO");
	    }
	}

	else if( o.x.dx<=72 )  //   Hint
	{
	  if(code != 41)
	  {
	  char *an;
	  int i,j,curr,flag=1;
	  settextstyle(6,0,4);

	  for(i=0;i<9;i++)
	    for(j=0;j<9;j++)
	      if(arr[i][j] != puzz[i][j])
		 { flag = 0; break; }

	  if(flag == 0 && cnt != 81)
	  {
	   while(1)
	   {
	    i =  abs(rand() % 9),j =  abs(rand() % 9);
	    if(stat[i][j]==0 && (arr[i][j]==0 || arr[i][j]!=puzz[i][j] ))
	       break;
	   }

	   curr = puzz[i][j];
	   stat[i][j] = arr[i][j] = hnt[i][j] = curr;
	   cnt++;

	   switch(curr)
	   {
	     case 1:   an="1";  break;
	     case 2:   an="2";  break;
	     case 3:   an="3";  break;
	     case 4:   an="4";  break;
	     case 5:   an="5";  break;
	     case 6:   an="6";  break;
	     case 7:   an="7";  break;
	     case 8:   an="8";  break;
	     case 9:   an="9";  break;
	     case 10:  an=" ";  break;
	   }

	  int l=((i*40)+150);
	  int t=((j*40)+100);

	  setcolor(BLACK);
	  for(int k=l+4;k<l+40-4;k++)
	     line(k,t+4,k,t+40-4);

	  setcolor(YELLOW);
	  outtextxy((i*40)+165 ,(j*40)+95 ,an);
	}}}

	else if( o.x.dx<=85 )  //   Submit
	{
	  Usr_Submit();
	}

	while(o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=72)
	{   frame(5,31,260,90,BLUE,BLUE,BLUE);
	    showmouse();  getmousepos();    }

	menubar();
	return;
     }
///////////////////////////////////////////////////////////////////////////
   if( o.x.cx>=86 && o.x.dx>=27 && o.x.cx<=130 && o.x.dx<=60
      && men_stat == 3 && puz_typ != 0)                     // reset
     {
	men_stat = 0;

	if(o.x.dx<=42)    // reset
	{
	  for(int i=0; i<9 ; i++)
	    for(int j=0; j<9 ; j++)
	    {
	       if( stat[i][j] == 0 && arr[i][j] != 0 )
	       {
		   arr[i][j] = 0;
	       }
	    }
	    code = 41;fill_maze();
	    code = 0;fill_maze();
	}

	else if( o.x.dx<=55 )   //   Timer
	{

	}

	while(o.x.cx>=86 && o.x.dx>=27 && o.x.cx<=130 && o.x.dx<=72)
	{   frame(5,31,260,90,BLUE,BLUE,BLUE);
	    showmouse();  getmousepos();    }

	menubar();
	return;
     }
//////////////////////////////////////////////////////////////////////////
   else if( o.x.cx>=5 && o.x.dx>=27 && o.x.cx<=66 && o.x.dx<=70 && men_stat == 1)
   {
      men_stat = 0;
      if( o.x.dx<=42 )  // save game to a file
       {
	  if( puz_typ <= 0)
	  {
	  fill_maze();
	  frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	  frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	  frame(196,186,424,200,BLUE,BLUE,BLUE);
	  setcolor(WHITE);
	  settextstyle(0,0,1);
	  outtextxy(270,190,"SAVE GAME");
	  setcolor(BLACK);
	  outtextxy(230,231," NO GAME TO SAVE");
	  delay(900);
	  Message_Box();
	  }

	  else
	  {
	  code = 48;
	  File_name[0] = '\0';
	  nam_siz = 0;
	  fill_maze();
	  frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	  frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	  frame(196,186,424,200,BLUE,BLUE,BLUE);
	  setcolor(WHITE);
	  settextstyle(0,0,1);
	  outtextxy(270,190,"SAVE GAME");
	  setcolor(BLACK);
	  outtextxy(203,211,"ENTER THE FILE NAME :  ");
	  frame(207,225,410,245,LIGHTGRAY,LIGHTGRAY,BLACK);
	  frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE);
	  frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE);
	  outtextxy(245,265,"OK");
	  outtextxy(343,265,"CANCEL");
	  }
       }

      else if( o.x.dx>=42 && o.x.dx<=55 )    // load
       {
	  code = 47; // load
	  File_name[0] = '\0';
	  nam_siz = 0;
	  fill_maze();
	  frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	  frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	  frame(196,186,424,200,BLUE,BLUE,BLUE);
	  setcolor(WHITE);
	  settextstyle(0,0,1);
	  outtextxy(260,190,"OPEN A FILE");
	  setcolor(BLACK);
	  outtextxy(203,211,"ENTER THE FILE NAME :  ");
	  frame(207,225,410,245,LIGHTGRAY,LIGHTGRAY,BLACK);
	  frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE);
	  frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE);
	  outtextxy(235,265,"OPEN");
	  outtextxy(343,265,"CANCEL");
      }

      else if( o.x.dx<=72 )
       {
	   code = 44; // quit
	   fill_maze();
	   frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	   frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	   frame(196,186,424,200,BLUE,BLUE,BLUE);
	   setcolor(WHITE);
	   settextstyle(0,0,1);
	   outtextxy(280,190,"MESSAGE");
	   setcolor(BLACK);
	   outtextxy(203,216,"DO YOU REALLY WANT TO ");
	   outtextxy(203,231,"EXIT ?");

	   frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE);
	   frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE);
	   outtextxy(240,265,"YES");
	   outtextxy(357,265,"NO");
       }
   }

   // new puzzle :-
   else if( o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70 && men_stat == 2)
   {
      men_stat = 0;

      for(int i=0;i<9;i++)
	for(int j=0;j<9;j++)
	     arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0;

      cnt = 0;
      Message_Box();    // clears the board
      if( o.x.dx<=42 )	   puz_typ = 1;    // EASY
      else if(o.x.dx<=55)  puz_typ = 2;    // MEDIUM
      else if(o.x.dx<=72)  puz_typ = 3;    // HARD

      generate_puzzle(puz_typ);
      fill_maze();

      while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70)
      {
	 frame(45,31,105,70,BLUE,BLUE,BLUE);
	 showmouse();getmousepos();
      }
      menubar();
      return;
   }

      // help
   else if( o.x.cx>=175 && o.x.dx>=31 && o.x.cx<=250 && o.x.dx<=60 && men_stat == 5)
     {
      men_stat = 0;
      if( o.x.dx<=42 )  // about
       {
	 fill_maze();
	 frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	 frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	 frame(196,186,424,200,BLUE,BLUE,BLUE);
	 setcolor(WHITE);
	 settextstyle(0,0,1);
	 outtextxy(280,190,"ABOUT");
	 setcolor(BLACK);
	 outtextxy(203,211,"Puzzle Sudoku ver. 1.3");
	 outtextxy(203,235,"For more details contact");
	 outtextxy(203,256," [email protected] ");
	 delay(3000);
       }

      else if( o.x.dx<=55 )  // credit
       {
	 fill_maze();
	 frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE);
	 frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE);
	 frame(196,186,424,200,BLUE,BLUE,BLUE);
	 setcolor(WHITE);
	 settextstyle(0,0,1);
	 outtextxy(270,190,"CREDITS");
	 setcolor(BLACK);
	 outtextxy(203,211," Made by :  ");
	 outtextxy(203,225,"   Tejas. A. Patil  ");
	 outtextxy(203,236,"   SE I.T MIT , Pune  ");
	 outtextxy(203,249,"I am thankful to my   ");
	 outtextxy(203,260,"Parents , Teachers and");
	 outtextxy(203,271,"Friends for their support");
	 outtextxy(203,282," and help.");
	 delay(3000);
       }
	 Message_Box();
	frame(5,31,260,90,BLUE,BLUE,BLUE);
	frame(45,31,105,70,BLUE,BLUE,BLUE);
	menubar();
   }

      // board
   if(o.x.cx>=150 && o.x.dx>=100 && o.x.cx<=510 && o.x.dx<=460)
   {
     int  xr = (o.x.cx-150)/40,
	  yr = (o.x.dx-100)/40;

     if(code > 40 ) return;
     if(puz_typ == 0 ) return;
     if(curr != 10 && arr[xr][yr] != 0)
	     Number_Pad(arr[xr][yr]-1);

     if(stat[xr][yr] != 0 ) return;
     if(cnt == 81 && curr != 10)    return;

     else
     {
	char *an;
	settextstyle(6,0,4);
	setcolor(LIGHTCYAN);
	switch(curr)
	{
	   case 1:   an="1"; break;
	   case 2:   an="2"; break;
	   case 3:   an="3"; break;
	   case 4:   an="4"; break;
	   case 5:   an="5"; break;
	   case 6:   an="6"; break;
	   case 7:   an="7"; break;
	   case 8:   an="8"; break;
	   case 9:   an="9"; break;
	   case 10:  an=" "; break;
       }

    do
    {
       if(curr != 10  &&  arr[xr][yr] == 0 && cnt != 81)
       { outtextxy((xr*40)+165, (yr*40)+95, an); }

       else if (curr == 10)
       {
	   int l=((xr*40)+150);
	   int t=((yr*40)+100);

	   setcolor(BLACK);
	   for(int k=l+4;k<l+40-4;k++)
	      line(k,t+4,k,t+40-4);

	   setcolor(WHITE);
       }
	   restrictmouse();
	   showmouse();
	   getmousepos();
    }
	while(o.x.cx>=((xr*40)+150) &&  o.x.dx>=((yr*40)+100) &&
	      o.x.cx<=((xr*40)+190) &&  o.x.dx<=((yr*40)+140)  );

       if(curr != 10  &&  arr[xr][yr] == 0 && cnt != 81)
	  cnt++;

       else if(curr == 10 && arr[xr][yr] != 0)  cnt--;

       arr[xr][yr] = (curr%10);
    }
  }

   if(o.x.cx>=40 && o.x.dx>=130 && o.x.cx<=70 && o.x.dx<=430 && code < 40
      && puz_typ != 0)
   {
      int p = (o.x.dx-130)/30;
      Number_Pad(p);
   }


   if(men_stat != 0)
   {
      men_stat = 0;
      frame(5,31,260,90,BLUE,BLUE,BLUE);
      menubar();
   }
}