Last active
October 1, 2016 16:07
-
-
Save normanfernandez/c8cf33b4d88be929373890030d213fcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cstdlib> | |
#include <ctime> | |
#define H 8 | |
#define V 8 | |
#define FILL_PROBABILITY 35 | |
#define BLANCO '+' | |
#define NEGRO '-' | |
#define AZUL 'B' | |
void draw(); | |
int block = 0; | |
using namespace std; | |
int matrix[H][V]; | |
int main(){ | |
srand(time(0)); | |
vector<int*> index = vector<int*>(); | |
for (int i = 0; i < H; i++) | |
for (int j = 0; j < V; j++) | |
matrix[i][j] = BLANCO; | |
for (int j = 0; j < H; j++) | |
for (int k = 0; k < V; k++) | |
if (rand() % 100 <= FILL_PROBABILITY) | |
{ | |
matrix[j][k] = NEGRO; | |
block++; | |
} | |
for (int i = 0; i < H; i++) | |
for (int j = 0; j < V; j++) | |
{ | |
int * ptr = &matrix[i][j]; | |
index.push_back(ptr); | |
} | |
draw(); | |
for (int i = 0; i < H; i++){ | |
bool flag = true; | |
for (int j = 0; j < V; j++){ | |
if (matrix[j][i] != NEGRO){ | |
matrix[j][i] = AZUL; | |
continue; | |
} | |
else{ | |
flag = false; | |
break; | |
} | |
} | |
if (flag){ | |
draw(); | |
cout << "percola" << endl; | |
cin.get(); | |
return 0; | |
} | |
} | |
draw(); | |
cin.get(); | |
return -1; | |
} | |
void draw() | |
{ | |
system("cls"); | |
for (int i = 0; i < H; i++){ | |
for (int j = 0; j < V; j++){ | |
cout << (char)matrix[i][j] << " "; | |
} | |
cout << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment