문를 본 부 ..--;;
는..^^;;
~cpp //12:50 //1:25 # include <stdio.h> # include <conio.h> # define SIZE 8 char P[SIZE][SIZE]; char Q[SIZE]; int c; int Check(int in) { int re=0; for(int i=c;i>0;i--){ if((in-i)>=0 && P[c-i][in-i] ==1){//.. return 0; } if( (in+i)<SIZE && P[c-i][in+i]==1 ){//른.. return 0; } } if (i==0) return 1; return 0; } int EQ() { int re; for(int i=0;i<SIZE;i++){ if(Q[i]==1) continue;// queen 는므 .. //면..리 놓 리는 .. if(Check(i)>0 ){//I 놓 .. Q[i]=1; P[c][i]=1; c++; if(c==SIZE){//는 .. return 1; } re=EQ(); if (re==1) return 1; c--; Q[i]=0; P[c][i]=0; } } return 0; } void Init() { for (int i=0;i<SIZE;i++){ for(int j=0;j<SIZE;j++) P[i][j]=0; Q[i]=0; } c=0; } void RESULT() { for(int i=0;i<SIZE;i++){ for(int j=0;j<SIZE;j++)printf("%d ",P[i][j]); printf("\n"); } } void main(void) { Init(); EQ(); RESULT(); getch(); return; }
번 문데..
EQ() return 1 는 대 ..
마막 만 를 .
리 메 는 루 .
EQ() return 1 는 대 ..
마막 만 를 .
리 메 는 루 .
~cpp //12:50 //1:25 # include <stdio.h> # include <conio.h> # define SIZE 8 char P[SIZE][SIZE]; char Q[SIZE]; int c; void RESULT() { static int count=0; count++; printf("solv %d\n",count); for(int i=0;i<SIZE;i++){ for(int j=0;j<SIZE;j++)printf("%d ",P[i][j]); printf("\n"); } printf("\n"); } int Check(int in) { int re=0; for(int i=c;i>0;i--){ if((in-i)>=0 && P[c-i][in-i] ==1){//.. return 0; } if( (in+i)<SIZE && P[c-i][in+i]==1 ){//른.. return 0; } } if (i==0) return 1; return 0; } int EQ() { int re; for(int i=0;i<SIZE;i++){ if(Q[i]==1) continue;// queen 는므 .. //면..리 놓 리는 .. if(Check(i)>0 ){//I 놓 .. Q[i]=1; P[c][i]=1; c++; if(c==SIZE){//는 .. // return 1; RESULT(); } re=EQ(); // if (re==1) return 1; c--; Q[i]=0; P[c][i]=0; } } return 0; } void Init() { for (int i=0;i<SIZE;i++){ for(int j=0;j<SIZE;j++) P[i][j]=0; Q[i]=0; } c=0; } void main(void) { Init(); EQ(); // RESULT(); getch(); return; }