#include #include #include #include #include int board[30][30]; int size; int next_x[8]={2,1,-1,-2,-1,-2,1,2},next_y[8] ={1,2,-2,-1,2,1,-2,-1}; int ok,min; int prob[30][30]; int posx[500],posy[500]; int nobat = 1 ; void end(); void xp(); void w98(); main() { int i,j,x1=0,y1=0; nobat=1; for(i=0;i<=size-1;i++){ for(j=0;j<=size-1;j++){ board[i][j]=0; }} for(i=0;i<400;i++){ posx[i]=0;posy[i]=0; } int x,y; do{ clrscr(); printf("Enter size of board (5-20): "); scanf("%d",&size); }while(size < 5 || size > 20); printf("Enter first point(x) : "); scanf("%d",&x); printf("Enter first point(y) : "); scanf("%d",&y); x--;y--; x=x%size;y=y%size; posx[0] = x; posy[0] = y; board[x][y]=1; //******************************************************************** prob[0][0]= prob[0][size-1]= prob[size-1][0]= prob[size-1][size-1]=2 ; prob[0][1]= prob[0][size-2]=prob[1][0]= prob[1][size-1]= prob[size-1][1]= prob[size-1][size-2]= prob[size-2][0] = prob[size-2][size-1]=3 ; prob[1][1]= prob[1][size-2]= prob[size-2][1]= prob[size-2][size-2]=4 ; for(i=2;i<=size-3;i++){ prob[i][0]=prob[i][size-1]=prob[0][i]=prob[size-1][i]=4; prob[i][1]=prob[i][size-2]=prob[1][i]=prob[size-2][i]=6; }//for for(i=2;i<=size-3;i++){ for(j=2;j<=size-3;j++){ prob[i][j]=8; }}//for //**************************************************************************** while ( nobat <= size * size ) { min = 8; for(int i=0 ;i<=7;i++){ if(x+next_x[i]<=size-1&&y+next_y[i]<=size-1 && x+next_x[i]>=0 &&y+next_y[i]>=0){ prob[x+next_x[i]][y+next_y[i]]-- ; if(prob[x+next_x[i]][y+next_y[i]] < min && board[x+next_x[i]][y+next_y[i]] == 0){ min = prob[x+next_x[i]][y+next_y[i]]; x1 = next_x[i];y1=next_y[i]; } }//if }//for x = x + x1 ; y = y + y1 ; posx[nobat] = x; posy[nobat] = y; board[x][y] = nobat++; }//while() nobat--; for(i=0;i<=size-1;i++){ for(j=0;j<=size-1;j++){ if(board[i][j]==0){printf("\n\n\tNO WAY");getch();end();} }} char c; while(c!='x' && c!='9'){ printf("\n\nWhat's your Windows :\n XP (press x)\n Win 98 or 2000(press 9)"); if((c=getch()) =='x') xp(); if(c =='9') w98(); } end(); return 0; } void end(){ gotoxy(24,25);printf("for exit press q,for repeat press r"); while(1){ char c=getch(); if(c=='q')exit(0); if(c=='r')main(); } } void xp(){ clrscr(); for(int i=0;i10){ setcolor(1); circle(120 + (400/size/2)+(400/size)*posx[i],40+(400/size/2)+(400/size)*posy[i], radius ); setfillstyle(1,1); floodfill(120 + (400/size/2)+(400/size)*posx[i],40+(400/size/2)+(400/size) *posy[i],1); setcolor(14); circle(120 + (400/size/2)+(400/size)*posx[i],40+(400/size/2)+(400/size)*posy[i], radius/3 ); setfillstyle(1,14); floodfill(120 + (400/size/2)+(400/size)*posx[i],40+(400/size/2)+(400/size) *posy[i],14); } else { setcolor(15); outtextxy(120 + (400/size/2)+(400/size)*posx[i],40+(400/size/2)+(400/size) *posy[i],itoa(i+1,s,10)); } getch(); setcolor(1); setfillstyle(1,1); floodfill(120 + (400/size/2)+(400/size)*posx[i],40+(400/size/2)+(400/size) *posy[i],1); } getch(); cleardevice(); }//w98()