8queen
---
---
~cpp #include<iostream> #include<ctime> using namespace std; void main() { // 는다... // srand(time(0)); // rand() 드값 다. // 면 때다 같값 만듭다. -_-;; // int x = rand(); // rand()는 랜덤 를 리는 다. // 리는 범는 0 ~ 무무 다. // int x1 = rand() % 10; // % 10 면 x1 는 10 나머가 될 는 // 0 ~ 9 까 가 랜덤게 들갑다. // int x2 = rand() % 9 + 1; // % 9를 면 0~9까 가 들 고 // 기 1 더면 1~10 까 가 됩다. srand(time(0)); //결기 int x = rand() % 6 +2; // do // { // int a = rand() % 7 int arr[8][8]= { {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8} }; //배 는 됬고 x를 .... //x가 2가 력 됬다고 각보... int i,j; for(i=1; i<9; i++) { i==x?arr[0][i-1]=x :arr[0][i-1]=0; } for(i=1; i<8; i++) { arr[i][x-1]=0; } //른 대각 0 로 만들기 for(i=1,j=0; x+j<8; i++,j++) { arr[i][x+j] = 0; } // 대각 0 로 만들기 for(i=1,j=2; x-j==0 ; i++,j++) { arr[i][x-j] = 0; } for(j=1; j<8; j++) { arr[i][x] //두 랜덤를 do { }while(a!=x-1&&a!=x+1) //두 배 대각 를 게 만들 보... //그 0 닌 랜덤 를 라... // 0 된 나 돌 ..... ... 렵다... ㅡㅜ;;