Skip to content

Instantly share code, notes, and snippets.

@normanfernandez
Last active October 1, 2016 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save normanfernandez/c8cf33b4d88be929373890030d213fcf to your computer and use it in GitHub Desktop.
Save normanfernandez/c8cf33b4d88be929373890030d213fcf to your computer and use it in GitHub Desktop.
#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