Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

랜웍/이진훈

From ZeroWiki
Revision as of 00:44, 27 March 2026 by Maintenance script (talk | contribs) (Repair batch-0005 pages from live compare)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
  1. include <iostream>
  2. include <ctime>

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; }