#include<iostream.h>
#include<conio.h>
#include<iostream>


void new_game();
char a[9][9];
char b[9][9];
char nr[9][9];
char lger[11][11];
int i_ger=0,j_ger=0,y;
int	equal=0;
int chike_equal_a_to_b=0;
int level=0,star=1;
char ger;

//#####################################################################################
void print_a()
{
	int w;
	int e;
	cout<<"    ############################################################\n";
	for(w=0;w<9;w++)
	{
		cout<<"    #   ";
		for(e=0;e<9;e++)
		{
			cout<<a[w][e];
			if(lger[w][e]==NULL)
				cout<<"    ";
			else 
			{
				if(lger[w][e]==NULL)
					cout<<"<-? ";  
				else 
					cout<<"<-! ";
			}
			if((e==2)||(e==5))
			cout<<"#    ";
			if(((w==2)||(w==5))&&(e==8))
			{
				cout<<"#";
				cout<<"\n    ###########################################################";
			}
		}
		cout<<"#";
		cout<<endl;
	}
	cout<<"    ############################################################\n";
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;}

//#####################################################################################
void print_b()
{
	int w;
	int e;
	char r=50,l,f;
	for(int i=0;i<169;i++)
	{
		r=r+1;
	}
	l=r+2;
	f=r+1;
	for(int pl=0;pl<=30;pl++)
		cout<<"\n";
	cout<<"\n                                 Level  - "<<level<<" -\n\n";
	cout<<"          ";//
	for(int rt=0;rt<=59;rt++)
		cout<<r;
	cout<<endl;
	for(w=0;w<9;w++)
	{
		cout<<"          "<<r<<"   ";
		for(e=0;e<9;e++)
		{
			cout<<b[w][e];
			{
				if((lger[w][e]==NULL)&&(nr[w][e]!='g'))
					cout<<"    ";
				else
					if((nr[w][e]=='g')&&(lger[w][e]!='*'))
						cout<<":   ";
					else 
					{
						if((b[w][e]==NULL)||(nr[w][e]=='g'))
							cout<<"<-? ";
						else 
							cout<<"<-  ";
					}
					if((e==2)||(e==5))
						cout<<l<<"    ";
					if(((w==2)||(w==5))&&(e==8))
					{
						cout<<r;
						cout<<"\n          ";
						cout<<r;
						for(int rt=0;rt<=57;rt++)
							cout<<f;
					}
			}
		}
		cout<<r;
		cout<<endl;
	}
	cout<<"          ";
	for(rt=0;rt<=59;rt++)
		cout<<r;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;
}

//##################################################################################
void print_help()
{
	char ui='s';
	do
	{
	int w;
	int e;
	char r=50,l,f;
	for(int i=0;i<169;i++)
	{
		r=r+1;
	}
	l=r+2;
	f=r+1;
	for(int pl=0;pl<=30;pl++)
		cout<<"\n";
	cout<<"                     Help   ";
	cout<<"The X is error";
	cout<<"       Level  - "<<level<<" -\n\n\n";
	cout<<"          ";//
	for(int rt=0;rt<=59;rt++)
		cout<<r;
	cout<<endl;
	for(w=0;w<9;w++)
	{
		cout<<"          "<<r<<"   ";
		for(e=0;e<9;e++)
		{
			cout<<b[w][e];
			{
				if((lger[w][e]==NULL)&&(nr[w][e]!='g'))
					cout<<"    ";
					
				else
					if((((nr[w][e]=='g')&&(lger[w][e]!='*'))&&(a[w][e]!=b[w][e]))&&(b[w][e]!=NULL))
						cout<<"X   ";
					else
						if((((nr[w][e]=='g')&&(lger[w][e]!='*'))&&(a[w][e]!=b[w][e]))&&(b[w][e]==NULL))
							cout<<":   ";
						else
							if((((nr[w][e]=='g')&&(lger[w][e]!='*'))&&(a[w][e]==b[w][e]))&&(b[w][e]!=NULL))
							cout<<"    ";
					
					if((e==2)||(e==5))
						cout<<l<<"    ";
					if(((w==2)||(w==5))&&(e==8))
					{
						cout<<r;
						cout<<"\n          ";
						cout<<r;
						for(int rt=0;rt<=57;rt++)
							cout<<f;
					}
			}
		}
		cout<<r;
		cout<<endl;
	}
	cout<<"          ";
	for(rt=0;rt<=59;rt++)
		cout<<r;
	cout<<endl;
	cout<<endl;
	cout<<endl;
	cout<<endl;cout<<endl;cout<<endl;
	
	
	cout<<"\t\t\t\t\t\t\tprees Esc to buck"<<endl;
	ui=getch();
	}while(ui!=27);
}
//##################################################################################
void eqealnrtonull()
{
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				nr[i][j]='f';
				lger[i][j]=NULL;
				
			}
		}
}
//##############################################################################
void chaik_equal_hor_up_down_2_6_3(int x,int y)
{
	int u,c;
	equal=0;
	if(((x<=5)&&(y<=8))&&((x>=3)&&(y>=6)))
		{
			u=3;
			c=5;
		}
	else
	{
		if(((x<=2)&&(y<=8))&&((x>=0)&&(y>=6)))
		{
			u=0;
			c=5;
		}
		else
		{
			if(((x<=2)&&(y<=5))&&((x>=0)&&(y>=3)))
			{
				u=0;
				c=2;
			}
		}
	}
	for(int v=x;v<(x+1);v++)
	{
		for(int b=u;b<=c;b++)
		{
			if(a[x][y]==a[v][b])
			{
				equal++;
			}
		}
	}
}
//#############################################################################
void chaik_equal_hor_up_down_4_7_8(int x,int y)

{
	int u,c;
	if(((x<=8)&&(y<=5))&&((x>=6)&&(y>=3)))
		{
			u=6;
			c=8;
		}
	else
	{
		if(((x<=8)&&(y<=2))&&((x>=6)&&(y>=0)))
		{
			u=3;
			c=8;
		}
		else
		{
			if(((x<=5)&&(y<=2))&&((x>=3)&&(y>=0)))
			{
				u=3;
				c=8;
			}
		}
	}
	equal=0;
	for(int v=x;v<(x+1);v++)
	{
		for(int b=u;b<=c;b++)
		{
			if(a[x][y]==a[v][b])
			{
				equal++;
			}
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
void exchang_2_6_3_hor_down(int i,int j)
{
	int temp,adad3=0;
	for(int t=0;t<2;t++)
	{
		chaik_equal_hor_up_down_2_6_3(i,j);
		if(equal!=0)
		{
			switch(adad3)
			{
			case 0:
				{
					temp=a[i+1][j];
					a[i+1][j]=a[i][j];
					a[i][j]=temp;
					adad3++;
				};break;
			case 1:
				{
					if((j==5)||(j==8))
					{
						temp=a[i+1][j-2];
						a[i+1][j-2]=a[i][j];
						a[i][j]=temp;
						adad3=0;
					}
					else
					{
						temp=a[i][j+1];
						a[i][j+1]=a[i][j];
						a[i][j]=temp;
						adad3=0;
					};break;
				}
			}
		}
	}
}
//#############################################################################
void exchang_4_7_8_hor_down(int i,int j)
{
	int temp,adad3=0;
	for(int t=0;t<2;t++)
	{
		chaik_equal_hor_up_down_4_7_8(i,j);
		if(equal!=0)
		{
			switch(adad3)
			{
			case 0:
				{
					temp=a[i+1][j];
					a[i+1][j]=a[i][j];
					a[i][j]=temp;
					adad3++;
				};break;
			case 1:
				{
					if((j==5)||(j==2))
					{
						temp=a[i+1][j-2];
						a[i+1][j-2]=a[i][j];
						a[i][j]=temp;
						adad3=0;
					}
					else
					{
						temp=a[i][j+1];
						a[i][j+1]=a[i][j];
						a[i][j]=temp;
						adad3=0;
					};break;
				}
			}
		}
	}
}
//#############################################################################
void exchang_2_6_3_hor_up(int i,int j)
{
	int temp,adad4=0;
	for(int t=0;t<2;t++)
	{
		chaik_equal_hor_up_down_2_6_3(i,j);
		if(equal!=0)
		{
			switch(adad4)
			{
			case 0:
				{
					temp=a[i-1][j];
					a[i-1][j]=a[i][j];
					a[i][j]=temp;
					adad4++;
				};break;
			case 1:
				{
					if((j==3)||(j==6))
					{
						temp=a[i-1][j+2];
						a[i-1][j+2]=a[i][j];
						a[i][j]=temp;
						adad4=0;
					}
					else
					{
						temp=a[i][j-1];
						a[i][j-1]=a[i][j];
						a[i][j]=temp;
						adad4=0;
					}
				};break;
			}
		}
	}
}
//#############################################################################
void exchang_4_7_8_hor_up(int i,int j)
{
	int temp,adad4=0;
	for(int t=0;t<2;t++)
	{
		chaik_equal_hor_up_down_4_7_8(i,j);
		if(equal!=0)
		{
			switch(adad4)
			{
			case 0:
				{
					temp=a[i-1][j];
					a[i-1][j]=a[i][j];
					a[i][j]=temp;
					adad4++;
				};break;
			case 1:
				{
					if((j==3)||(j==0))
					{
						temp=a[i-1][j+2];
						a[i-1][j+2]=a[i][j];
						a[i][j]=temp;
						adad4=0;
					}
					else
					{
						temp=a[i][j-1];
						a[i][j-1]=a[i][j];
						a[i][j]=temp;
						adad4=0;
					}
				};break;
			}
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################

//#############################################################################

//#############################################################################
void edite_2_hor_down()
{
	for(int i=0;i<2;i++)
	{
		for(int j=3;j<=5;j++)
		{
			exchang_2_6_3_hor_down(i,j);
		}
	}
}
//##########################################################################
void edite_2_hor_up()
{
	for(int i=2;i>0;i--)
	{
		for(int j=5;j>=3;j--)
		{
			exchang_2_6_3_hor_up(i,j);
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
void edite_3_hor_down()
{
	for(int i=0;i<2;i++)
	{
		for(int j=6;j<=8;j++)
		{
			exchang_2_6_3_hor_down(i,j);
		}
	}
}
//#############################################################################
void edite_3_hor_up()
{
	for(int i=2;i>0;i--)
	{
		for(int j=8;j>=6;j--)
		{
			exchang_2_6_3_hor_up(i,j);
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
void edite_4_hor_down()
{
	for(int i=3;i<5;i++)
	{
		for(int j=0;j<=2;j++)
		{
			exchang_4_7_8_hor_down(i,j);
		}
	}
}
//##########################################################################
void edite_4_hor_up()
{
	for(int i=5;i>3;i--)
	{
		for(int j=2;j>=0;j--)
		{
			exchang_4_7_8_hor_up(i,j);
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
void edite_6_hor_down()
{
	for(int i=3;i<5;i++)
	{
		for(int j=6;j<=8;j++)
		{
			exchang_2_6_3_hor_down(i,j);
		}
	}
}
//###########################################################
void edite_6_hor_up()
{
	for(int i=5;i>3;i--)
	{
		for(int j=8;j>=6;j--)
		{
			exchang_2_6_3_hor_up(i,j);
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
void edite_7_hor_down()
{
	for(int i=6;i<8;i++)
	{
		for(int j=0;j<=2;j++)
		{
			exchang_4_7_8_hor_down(i,j);
		}
	}
}
//##########################################################################
void edite_7_hor_up()
{
	for(int i=8;i>6;i--)
	{
		for(int j=2;j>=0;j--)
		{
			exchang_4_7_8_hor_up(i,j);
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
void edite_8_hor_down()
{
	for(int i=6;i<8;i++)
	{
		for(int j=3;j<=5;j++)
		{
			exchang_4_7_8_hor_down(i,j);
		}
	}
}
//##########################################################################
void edite_8_hor_up()
{
	for(int i=8;i>6;i--)
	{
		for(int j=5;j>=3;j--)
		{
			exchang_4_7_8_hor_up(i,j);
		}
	}
}
//#############################################################################

//#############################################################################

//#############################################################################
//#############################################################################
void chiake_array_by_plus()
{
	int tr=0;
	for(int i=0;i<9;i++)
	{
		cout<<tr<<"\n";
		tr=0;
		for(int j=0;j<9;j++)
		{
			tr=tr+a[i][j];
		}
	}
	cout<<tr<<"\n";
	tr=0;
	for(int ii=0;ii<9;ii++)
	{
		cout<<tr<<"\n";
		tr=0;
		for(int j=0;j<9;j++)
		{
			tr=tr+a[j][ii];
		}
	}
	cout<<tr<<"\n";
}
//#############################################################################
void enter_data_1st_time()
{
	int s=0;
	int r=s+2;
	int m=s;
	int n=m+2;
	int adad1=0;
	int adad2=0;
	int d=0;
	char q=48;//ascce code for 0
	{
		while(d==0)
		{
			d++;
			{
				for(int i=s;i<=r;i++)
				{
					for(int j=m;j<=n;j++)
					{
						a[i][j]=((rand()%9)+49);
						
					}
				}
				adad1++;
				adad2++;
				d=0;
				m=m+3;
				n=n+3;
				if(adad1==3)
				{
					adad1=0;
					s=s+3;
					r=r+3;
					m=0;
					n=2;
				}
				if(adad2==9)
					d=1;
			}
		}
	}


for( int ii=0;ii<100;ii++)
{
for(int i=0;i<3;i++)
{
	for( int j=0;j<3;j++)
	{	
		for(int w=0;w<3;w++)
		{
			for(int q=0;q<3;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}
for(  ii=0;ii<100;ii++)
{
for(int i=0;i<3;i++)
{
	for( int j=3;j<=5;j++)
	{	
		for(int w=0;w<3;w++)
		{
			for(int q=3;q<=5;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}

for(  ii=0;ii<100;ii++)
{
for(int i=0;i<3;i++)
{
	for( int j=6;j<=8;j++)
	{	
		for(int w=0;w<3;w++)
		{
			for(int q=6;q<=8;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}
for(  ii=0;ii<100;ii++)
{
for(int i=3;i<=5;i++)
{
	for( int j=0;j<=2;j++)
	{	
		for(int w=3;w<=5;w++)
		{
			for(int q=0;q<=2;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}

for(  ii=0;ii<100;ii++)
{
for(int i=3;i<=5;i++)
{
	for( int j=3;j<=5;j++)
	{	
		for(int w=3;w<=5;w++)
		{
			for(int q=3;q<=5;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}

for(  ii=0;ii<100;ii++)
{
for(int i=3;i<=5;i++)
{
	for( int j=6;j<=8;j++)
	{	
		for(int w=3;w<=5;w++)
		{
			for(int q=6;q<=8;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}


for(  ii=0;ii<100;ii++)
{
for(int i=6;i<=8;i++)
{
	for( int j=0;j<=2;j++)
	{	
		for(int w=6;w<=8;w++)
		{
			for(int q=0;q<=2;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}

for(  ii=0;ii<100;ii++)
{
for(int i=6;i<=8;i++)
{
	for( int j=3;j<=5;j++)
	{	
		for(int w=6;w<=8;w++)
		{
			for(int q=3;q<=5;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}


for(  ii=0;ii<100;ii++)
{
for(int i=6;i<=8;i++)
{
	for( int j=6;j<=8;j++)
	{	
		for(int w=6;w<=8;w++)
		{
			for(int q=6;q<=8;q++)
			{
				if((i==w)&&(j==q))
					y=0;
				else
				{
					if(a[i][j]==a[w][q])
					{
						if(a[i][j]==57)
							a[i][j]=49;
						else
							a[i][j]=a[i][j]+1;
					}
				}
			}
		}
	}
}
}

}
//#############################################################################
void make_sodoko_array()
{
	int xcv,zx;
	char c[9][9];
	
	do
	{enter_data_1st_time();
		for(int gh=0;gh<10;gh++)
		{for(int gh=0;gh<10;gh++)
		{
			edite_2_hor_down();
			edite_2_hor_up();
			edite_6_hor_down();
			edite_6_hor_up();
			edite_3_hor_down();
			edite_3_hor_up();
		
			edite_4_hor_down();
			edite_4_hor_up();
			edite_8_hor_down();
			edite_8_hor_up();
			edite_7_hor_down();
			edite_7_hor_up();
		
		}
		
		zx=0;
		xcv=0;
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
				xcv=xcv+a[i][j];
			if(xcv==477)
				zx++;
			xcv=0;
		}
		xcv=0;
		for( i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
				xcv=xcv+a[j][i];
			if(xcv==477)
				zx++;
			xcv=0;
		}
		
		if(zx!=18)
		{
			for( i=0;i<9;i++)
			{
				for(int j=0;j<9;j++)
					c[i][j]=a[i][j];
			}
			for( i=0;i<9;i++)
			{
				for(int j=0;j<9;j++)
					a[i][j]=c[8-j][i];
			}
			
			
		}}
}
	while(zx!=18);
}

//#############################################################################
void write_suduku_by_asiccode()
{
	char r=50;
	for(int i=0;i<169;i++)
	{
		r=r+1;
	}
	cout<<endl<<endl<<endl;
	cout<<"\t";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"\t\t\t";
	for( i=0;i<2;i++)
		cout<<r;
	cout<<"\t\t";
	for( i=0;i<2;i++)
		cout<<r;
	cout<<endl<<"\t"<<r<<r<<"\t\t\t\t"<<r<<r<<"\t\t"<<r<<r<<"   "<<r<<r;
	cout<<endl<<"\t"<<r<<r<<"\t\t\t\t"<<r<<r<<"\t\t"<<r<<r<<"  "<<r<<r;
	cout<<endl<<"\t"<<r<<r<<"\t\t\t\t"<<r<<r<<"\t\t"<<r<<r<<" "<<r<<r;
	cout<<endl<<"\t";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  ";
	for( i=0;i<2;i++)
		cout<<r;
	cout<<"      "<<r<<r<<"  ";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  ";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  "<<r<<r<<r<<r<<"     "<<r<<r<<"      "<<r<<r;
	cout<<endl<<"\t\t"<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<" "<<r<<r<<"    "<<r<<r<<"      "<<r<<r;
	cout<<endl<<"\t\t"<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"  "<<r<<r<<"   "<<r<<r<<"      "<<r<<r;
	cout<<endl<<"\t\t"<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<"  "<<r<<r<<"   "<<r<<r<<"  "<<r<<r<<"      "<<r<<r;
	cout<<endl<<"\t";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  ";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  ";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  ";
	for( i=0;i<10;i++)
		cout<<r;
	cout<<"  "<<r<<r<<"    "<<r<<r<<" "<<r<<r<<r<<r<<r<<r<<r<<r<<r<<r;
	cout<<endl;
	cout<<endl<<"\t";
	for( i=0;i<67;i++)
		cout<<r;
	cout<<endl<<endl<<endl<<endl;
}
//#############################################################################
void equal_b_to_a()
{
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			b[i][j]=a[i][j];
		}
	}
}
//#############################################################################
void chaik_equal_b_to_a()
{
	chike_equal_a_to_b=0;
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			if(b[i][j]=a[i][j])
				chike_equal_a_to_b++;
		}
	}
	cout<<endl<<chike_equal_a_to_b<<endl;
}
//#############################################################################
void main_menu()
{
	if(level!=0)
	{
		if(star==0)
			cout<<"\t\t\t\t*  ";
		else  
			cout<<"\t\t\t\t   ";
		cout<<"Contenu"<<endl;
	}
	if(star==1)
		cout<<"\t\t\t\t*  ";
	else  
		cout<<"\t\t\t\t   ";
	cout<<"New Game"<<endl;
	if(star==2) 
		cout<<"\t\t\t\t*  ";
	else
		cout<<"\t\t\t\t   ";
	cout<<"Key Setting"<<endl;
	if(star==3)
		cout<<"\t\t\t\t*  ";
	else
		cout<<"\t\t\t\t   ";
	cout<<"How To Play"<<endl;
	if(star==4)
		cout<<"\t\t\t\t*  ";
	else
		cout<<"\t\t\t\t   ";
	cout<<"About Us"<<endl;
	if(star==5)
		cout<<"\t\t\t\t*  ";
	else
		cout<<"\t\t\t\t   ";
	cout<<"Exite\n\n\n"<<endl;
}
//#############################################################################
void move_ger()
{
	do
	{
		ger=getch();
		if(ger==27)
		{
			star=5;
			break;
		}
		if(ger==72)
			star--;
		if(ger==80)
			star++;
		if(star==6)
		{
			if(level==0)
				star=1;
			else
				star=0;
		}
		if((level==0)&&(star==0))
			star=5;
		if((level!=0)&&(star==-1))
			star=5;
		write_suduku_by_asiccode();
		main_menu();
	}
	while(ger!=13);
}
//#############################################################################
void how_to_play()
{
	char me;
	do
	{
		cout<<"\n\n\n\n\n\n\n\n\n\n\n\nenter value in empty place in three condetion\n\nfirst the entered do not write befor in vertecale\n\nsecond the entered do not write befor in horezantel\n\ntherd the entered do not write befor in small sqwer \n\n*note:do not wore to time\n\n\n\n\n"<<endl; 
		cout<<"\t\t\t\t\t\tprees Esc to back"<<endl;
		me=getch();
	}while(me!=27);
}
//##################
void key_setting()
{
	char me;
	do
	{
		cout<<"\n\n\n\n\n\n\nprees enter for ok\n\nprees up to mov up ^\n\nprees down to down v\n\nprees right to right ->\n\nprees lift to lift <-\n\nprees space to help\n\nprees + to next level\n\nprees - to previous level\n\n\n"<<endl;
		cout<<"prees Esc to back\n"<<endl;
		me=getch();
	}while(me!=27);
}
//##################
void abuot_us()
{
	char me;
	do
	{
		cout<<"\n\n\n\n\n\n\n\n\nthis program programmed by saleem salim \n2009_7_8@copy right its bettwen your hands\n\n\n\n\n\n\n\n\n\n\n"<<endl;
		cout<<"prees Esc to back\n\n"<<endl;
		me=getch();
	}while(me!=27);
}
//#############################################################################
void delete_some_value_from_b_by_level()//
{
	for(int s=0;s<level;s++)
	{
	int i=(rand()%9);
	int j=(rand()%9);
		{
			
			b[i][j]=NULL;
			lger[i][j]=' ';
			nr[i][j]='g';
			
		}
	}
}
//#############################################################################
void write_next_level()
{
	char r=50;
	for(int i=0;i<169;i++)
	{
		r=r+1;
	}
	cout<<"\n\n\n\n\n\n\n\n\n\n"<<endl; 
	cout<<"\t"<<r<<r<<"    "<<r<<r<<"                  "<<r<<r<<"      "<<r<<r<<"                           "<<r<<r<<endl;
	cout<<"\t"<<r<<r<<r<<"   "<<r<<r<<"                 "<<r<<r<<r<<r<<"     "<<r<<r<<"                           "<<r<<r<<endl;
	cout<<"\t"<<r<<r<<" "<<r<<"  "<<r<<r<<"  "<<r<<r<<r<<"   "<<r<<r<<"  "<<" "<<r<<r<<"   "<<r<<r<<"      "<<r<<r<<"     "<<r<<r<<r<<"   "<<r<<r<<"  "<<"  "<<r<<r<<"  "<<r<<r<<r<<"   "<<r<<r<<endl;
	cout<<"\t"<<r<<r<<"  "<<r<<" "<<r<<r<<"  "<<r<<r<<r<<"    "<<r<<r<<" "<<r<<r<<"    "<<r<<r<<"      "<<r<<r<<"     "<<r<<r<<r<<"    "<<r<<r<<"  "<<r<<r<<"   "<<r<<r<<r<<"   "<<r<<r<<endl;
	cout<<"\t"<<r<<r<<"   "<<r<<r<<r<<"  "<<r<<r<<"      "<<r<<r<<r<<"     "<<r<<r<<"      "<<r<<r<<"     "<<r<<r<<"      "<<r<<r<<r<<r<<"    "<<r<<r<<"    "<<r<<r<<endl;
	cout<<"\t"<<r<<r<<"    "<<r<<r<<"  "<<r<<r<<r<<r<<r<<" "<<r<<r<<r<<" "<<r<<r<<r<<"   "<<r<<r<<"      "<<r<<r<<r<<r<<r<<r<<" "<<r<<r<<r<<r<<r<<"    "<<r<<r<<"     "<<r<<r<<r<<r<<r<<" "<<r<<r<<endl;
	cout<<"\n\n\n\n\n\n\n\n\n\n"<<endl;
}
//#############################################################################
void equal_lger_to_null()
{
	for(int qw=-1;qw<10;qw++)
	{
		for(int wq=-1;wq<10;wq++)
			lger[qw][wq]=NULL;
	}
}
//#############################################################################
void main();

void move_ger2_play()
{
	char ger2='s';

	do
	{
		print_b();
		cout<<"prees space to help";
		cout<<"\t      prees del to delete \t      prees Esc to back"<<endl;
		lger[i_ger][j_ger]=NULL;
		if(ger2!=27)
			ger2=getch();
		
		if(ger2==27)main();
		if(ger2=='&')
			print_a();




		if(ger2=='+')
		{	
		
			write_next_level();
			cout<<"Prees any key to contenu"<<endl;
			char re;re=getch();
			i_ger=0;
			j_ger=0;
			new_game();
		}




		if(ger2=='-')
		{	
			if(level!=1)
				{level=level-2;
			

	

		
			write_next_level();
			cout<<"Prees any key to contenu"<<endl;
			char re;re=getch();
			i_ger=0;
			j_ger=0;
			
				new_game();}
		}




		if((ger2==8)&&((b[i_ger][j_ger]==NULL)||(nr[i_ger][j_ger]=='g')))
			b[i_ger][j_ger]=NULL;
		if(ger2==32)
			print_help();
		if(((ger2>='1')&&(ger2<='9'))&&(nr[i_ger][j_ger]=='g'))
			b[i_ger][j_ger]=ger2;
		int q=0;
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				if(a[i][j]==b[i][j])
					q++;
			}
		}
		if(q==81)
		{
			write_next_level();
			cout<<"Prees any key to contenu"<<endl;
			char re;re=getch();
			i_ger=0;
			j_ger=0;
			new_game();
		}
		
		if(ger2==72)
		{
			i_ger--;
			if(i_ger==-1)
				i_ger=8;
		}
		if(ger2==80)
		{
			i_ger++;
			if(i_ger==9)
				i_ger=0;
		}
		if(ger2==75)
		{
			j_ger--;
			if(j_ger==-1)
				j_ger=8;
		}
		if(ger2==77)
		{
			j_ger++;
			if(j_ger==9)
				j_ger=0;
		}
		lger[i_ger][j_ger]='*';
	}while(ger2!=27);
}
//#############################################################################
void new_game()
{
	eqealnrtonull();
	level++;star=0;
	make_sodoko_array();
	equal_b_to_a();
	delete_some_value_from_b_by_level();
	lger[0][0]='*';
	move_ger2_play();
	cout<<endl<<endl<<endl;
	print_b();
}
//#############################################################################
void countenu()
{
	move_ger2_play();
}
//#############################################################################
void main()
{
	char ex=0;
	do
	{
		write_suduku_by_asiccode();
		main_menu();
		move_ger();
		switch(star)
		{
		case 0:countenu();break;
		case 1:new_game();break;
		case 2:key_setting();break;
		case 3:how_to_play();break;
		case 4:abuot_us();break;
		case 5:exit(-1);break;
		} 
	}while(ex!='e');
}