#include #include using namespace std; const int Arsize = 3; int pan[3][3] = { {0,0,0}, {0,0,0}, {0,0,0} }; int count = 1; int countz(); void main() { srand(time(0)); int x = rand()%3; int y = rand()%3; int a = 0 , b = 0; int z = countz(); while(z) { x = x+a; y = y+b; pan[x][y] = 1; do { a = rand()%3 - 1; b = rand()%3 - 1; if (a == 0 && b == 0) continue; else if ((x+a >= 0 && x+a < 3) && (y+b >= 0 && y+b < 3)) break; }while(true); count++; z = countz(); } for (int i = 0;i<3;i++)//출력부.. { for (int k = 0;k<3;k++) cout << pan[i][k]; cout << endl; } } int countz()//빈칸없나 체크하는 함수. { int k = 0; for (int i = 0;i<3;i++) for(int j = 0;j<3;j++) { if (pan[i][j] == 0) k++; } return k; }