Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <iostream>

#include <math.h>
#include <conio.h>

using namespace System;


using namespace std;

void crearMatriz(char **&m, int cf, int cc) {


m = new char* [cf];
for (size_t i = 0; i < cf; i++)
{
m[i] = new char[cf];
}

void cargaDatos(char**& m, int cf, int cc) {


Random aleatorio;

for (int i = 0; i < cf; i++)


{
for (int j = 0; j < cc; j++)
{
int letra = aleatorio.Next(0.3);
if (letra == 0) m[i][j] = 'R';
if (letra == 1) m[i][j] = 'N';
if (letra == 2) m[i][j] = 'B';

}
}

void imprimedatos(char**& m, int cf, int cc) {


for (int i = 0; i < cf; i++)
{
for (int j = 0; j < cc; j++)
{
cout << m[i][j] << " ";

}
cout << endl;
}
}

void frecuencias(char**& m, int cf, int cc) {


int kr = 0, kn = 0, kb = 0;
for (int i = 0; i < cf; i++)
{
for (int j = 0; j < cc; j++)
{
if (m[i][j] == 'R') kr++;
if (m[i][j] == 'N') kn++;
if (m[i][j] == 'B') kb++;

}
}

cout << "\nMenor cantidad:";


if (kr < kb && kr < kn) cout << "Rojas" << endl;
if (kb < kr && kb < kn) cout << "Blancas" << endl;
if (kn < kb && kn < kr) cout << "Negras" << endl;

cout << "\nMayor cantidad:";


if (kr > kb && kr > kn) cout << "Rojas" << endl;
if (kb > kr && kb > kn) cout << "Blancas" << endl;
if (kn > kb && kn > kr) cout << "Negras" << endl;

void quinuaespecial(char**& m, int cf, int cc) {


for (int i = 1; i < cf-1; i++)
{
for (int j = 1; j < cc-1; j++)
{
if (m[i][j-1]=='B'&&m[i][j+1]=='N'&& m[i-1][j]=='R'&& m[i]
[j]=='R' && m[i-1]
[j-1]=='N'&& m[i-1][j+1]=='B')
{
cout << "Fila" << i << "-" << "Columna" << j << endl;
}

}
}
}

void main() {
int filas = 10, columna = 15;
char** matriz;
crearMatriz(matriz, filas, columna);
cargaDatos(matriz, filas, columna);
imprimedatos(matriz, filas, columna);
frecuencias(matriz, filas, columna);
quinuaespecial(matriz, filas, columna);

system("pause>>null");

You might also like