It turns out that I'm doing a program that generates an array with random numbers, the program worked, but I changed some things to improve it. and it is executed but after generating 2 random values to compare them in the array, I see an advantage "I stop working". I'm working on the "numbers" method, that method will search if the number generated is in the array and if it is, that number will be changed to "178" which is the ASCII code that I chose to use to show it crossed out.
#include <stdio.h>
#include <gotoxy.h>
#include <time.h>
#include<stdlib.h>
#include <stdbool.h>
int numeros(int bingo1[5][5], int i);
int Aleatorio (int inicial)
{
return rand() % 15 + inicial;
}
bool Verificador(int numero, int columna, int bingo1 [5][5], int colum, int k, int a)
{
int j, q;
if (k==2){ j=colum; q=a;}else{j=columna; q=numero;}
for(int i=4 ;i>=0;i--)
{
if(q==bingo1[j][i])
{
if(k==2){numeros(0,i); }
return true;
}
}
return false;
}
int carton1 ()
{
int x=3, bingo1 [5][5];
for (int a=1; a<=2;a++)
{
int fila, columna, y=3, numero, inicial=1;
srand(time(NULL));
for (columna=0; columna<5; columna++)
{
for(fila=0; fila<5; fila++)
{
do
{
numero= Aleatorio(inicial);
}
while(Verificador(numero, columna, bingo1, 0,0,0) == true);
bingo1[columna][fila]=numero;
}
inicial=inicial + 15;
}
if (a==1){gotoxy(11,2); printf("BINGO | %d |",a);}
else{gotoxy(48,2); printf("BINGO | %d |", a);}
for (fila=0; fila<5; fila++)
{
for (columna=0; columna<5; columna++)
{
gotoxy(x,y); printf("| %d |", bingo1[columna][fila]);
x=x+5;
}
y=y + 2;
x=x-25;
}
x=x+37;
}
numeros(bingo1, 0);
}
int numeros(int bingo1[5][5], int i)
{
int a, fil, colum, k=2, n=3,m=3;
for (int c=1; c<=25; c++)
{
a=rand() % 75 + 1;
gotoxy(20,15);printf("EL NUMERO ALEATORIO ES: %d ", a);
gotoxy(20,16);system("PAUSE");
for (colum=0; colum<5; colum++)
{
if( Verificador(0,0,bingo1,colum,k,a) == true);
{
bingo1[colum][i]=178;
}
}
for (fil=0; fil<5; fil++)
{
for (colum=0; colum<5; colum++)
{
gotoxy(n,m); printf("| %d |", bingo1[colum][fil]);
n=n+5;
}
m=m + 2;
n=n-25;
}
}
}
int main ()
{
carton1();
return 0;
}