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

랜웍/이진훈: Difference between revisions

From ZeroWiki
imported>Unknown
No edit summary
 
(Repair batch-0005 pages from live compare)
 
Line 1: Line 1:
#include <iostream>
#include <iostream>
#include &lt;ctime&gt;
#include <ctime>
using namespace std;
using namespace std;


Line 58: Line 58:
return k;
return k;
}
}

Latest revision as of 00:44, 27 March 2026

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