.. 고, 각 값 .
~cpp #include <iostream> using namespace std; void main() { int board[8][8]; int firstBoard[8][8]; int y2nd, x2nd, setx = 0; int y3rd, same = 0; int impossible = 0; int y4th, x4th; int y5th, x5th; int y6th, x6th; int y7th, x7th; int findY, findX; int originX, firstFind,firstAnswer = 1; int endFind = 0, count = 0; for(int y1st = 0 ; y1st < 8 ; y1st++) { for(int x1st = 0 ; x1st < 8 ; x1st++) { board[x1st][y1st] = 0; firstBoard[x1st][y1st] = 0; } } do // 과 까 기 { impossible = 0; for(y2nd = 0 ; y2nd < 8 ; y2nd++) // { setx = 0; firstFind = 1; do //꿔 기 { same = 0; x2nd = setx; if(firstFind == 1) { originX = x2nd; firstFind = 0; } board[y2nd][x2nd] = 1; for(y3rd = 0 ; y3rd < 8 ; y3rd) // 기 // { if (board[y3rd][x2nd] == board[y2nd][x2nd]) same = 1; } if (same == 0) // 각 { findY = y2nd - 1; findX = x2nd - 1; while( (findY != -1) && (findX != -1)) { if(board[findY][findX] == 1) same = 1; findY -= 1; findX -= 1; } } if (same == 0) // 각 { findY = y2nd + 1; findX = x2nd - 1; while( (findY != 8) && (findX != -1)) { if(board[findY][findX] == 1) same = 1; findY += 1; findX -= 1; } } if (same == 0) // 각 { findY = y2nd - 1; findX = x2nd + 1; while( (findY != -1) && (findX != 8)) { if(board[findY][findX] == 1) same = 1; findY -= 1; findX += 1; } } if (same == 0) // 각 { findY = y2nd + 1; findX = x2nd + 1; while( (findY != 8) && (findX != 8)) { if(board[findY][findX] == 1) same = 1; findY += 1; findX += 1; } } if (same == 1) //공격 기 꾸기 { board[y2nd][x2nd] = 0; setx++; } if (setx == 8) setx = 0; if (originX == setx ) impossible = 1; // 기 if (impossible == 1) break; } while (same == 1); if (impossible == 1) break; } if (firstAnswer == 0) // 과 { for(y7th = 0 ; y7th < 8 ; y7th++) { for(x7th = 0 ; x7th < 8 ; x7th++) { if( firstBoard[y7th][x7th] != board[y7th][x7th]) count++; } } } if (count == 0) endFind = 1; // else count = 0; if (impossible == 0) { if (firstAnswer == 1) // { for(y6th = 0 ; y6th < 8 ; y6th++) { for(x6th = 0 ; x6th < 8 ; x6th++) { firstBoard[y6th][x6th] = board[y6th][x6th]; } } firstAnswer = 0; } } if(endFind == 0) { if (impossible == 0) { for(y4th = 0 ; y4th < 8 ; y4th++) // { for(x4th = 0 ; x4th < 8 ; x4th++) { cout<<"board[y3th][x4th]\t"; } cout<<endl; } cout<<endl<<endl; } for(y5th = 0 ; y5th < 8 ; y5th++) //기 { for(x5th = 0 ; x5th < 8 ; x5th++) { board[x5th][y5th] = 0; } } } }while(endFind == 0); }