#include #include #include #include int Queen(int,int); // check kardan baraee inke befahme ke vazir . vaziro nazane void Draw (void); // tabe rasme safhe shatranj void fill_circle(int,int,int,int); // tabe por kardan dayere haa int shat[8][8]; // safeh shatranj 8 * 8 main(){ int driver=DETECT,mode=0,q=1; initgraph(&driver,&mode,""); // bordan be halate gerafiki for(int i=0;i<8;i++) for(int j=0;j<8;j++) shat[i][j]=0; // khone hae shatranjo 0 kardan for(int a=0;a<8;a++){ shat[0][a]=1; for(int b=0;b<8;b++){ shat[1][b]=1; if(Queen(1,b)==0) for(int c=0;c<8;c++){ shat[2][c]=1; if(Queen(2,c)==0) for(int d=0;d<8;d++){ shat[3][d]=1; if(Queen(3,d)==0) for(int e=0;e<8;e++){ shat[4][e]=1; if(Queen(4,e)==0) for(int f=0;f<8;f++){ shat[5][f]=1; if(Queen(5,f)==0) for(int g=0;g<8;g++){ shat[6][g]=1; if(Queen(6,g)==0) for(int h=0;h<8;h++){ shat[7][h]=1; if(Queen(7,h)==0){ Draw(); gotoxy(1,1); // bordan be makan 1,1 safhe monitor cout<<"Press Enter for Contniue "; gotoxy(1,2); cout<<"Press 0 for Exit"; cout<<"\nStage = "<=0 && err==0;i--){ // check kardan be samte chap if(shat[i][j]!=0) err=1; } for(i=x+1,j=y+1;i<8 && j<8 && err==0;i++,j++){// check kardan PAIIN be samte RAST if(shat[i][j]!=0) err=1; } for(i=x-1,j=y-1;i>=0 && j>=0 && err==0;i--,j--){// check kardan BA'LLA be samte CHAP if(shat[i][j]!=0) err=1; } for(i=x-1,j=y+1;i>=0 && j<8 && err==0;i--,j++){// check kardan BA'LLA be samte RAST if(shat[i][j]!=0) err=1; } for(i=x+1,j=y-1;i<8 && j>=0 && err==0;i++,j--){// check kardan PAIIN be samte CHAP if(shat[i][j]!=0) err=1; } return (err); } /****************************************************************************** *******************************************************************************/ void Draw (void){ int c=0,y=90; cleardevice(); // pak kardan safhe monitor while(c<9){ setcolor(12); // tagir range galam line(140,y,500,y); // rasme khat c++; y+=40; } c=0; y=140; while(c<9){ setcolor(12); line(y,90,y,410); c++; y+=45; } for(int i=1;i<=8;i++) for(int j=1;j<=8;j++) if(shat[i-1][j-1]==1){ fill_circle(117+(j*45),70+(i*40),10,14); } } /****************************************************************************** *******************************************************************************/ void fill_circle(int x,int y,int r,int c){ setcolor(c); while(r){ circle(x,y,r);// rasme dayere r--; } }