Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- srand(time(0));
- int const size = 10;
- int arr[size][size];
- int oneCount = 0;
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size; j++)
- {
- arr[i][j] = 0;
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- //Paint first level board
- for (int n = 0; n < 4; n++)
- {
- int x, y;
- do
- {
- x = rand()%10;
- y = rand()%10;
- } while (arr[x][y] != 0);
- for (int i = y - 1; i < y + 2; i++)
- {
- for (int j = x - 1; j < x + 2; j++)
- {
- if (i >= 0 && j >= 0 && i < size && j < size)
- arr[j][i] = 2;
- }
- }
- arr[x][y] = 1;
- }
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size; j++)
- cout << arr[i][j] << " ";
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement