-1
I was solving a college exercise on matrices and I ended up crashing.
Ex: Build a program to automatically generate numbers between 0 and 99 from a bingo card. Knowing that each card should contain 5 lines of 5 numbers, generate this data so that it does not have repeated numbers inside the cards. The program must display on the screen the generated card.
I tried to solve it this way :
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define n 5
int main ()
{
int a[n][n],cont;
srand(time(NULL));
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
a[i][j]==-1;
}
}
// Preencher a matriz com valores n repitidos o "do/while" compararia td os valores da matriz e caso tenha repeticao aumemta um contador q executa o looping
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
do
{
cont=0;
a[i][j]=rand()%99;
for (int l=0;l<n;l++)
{
for (int c=0;c<n;c++)
{
if (a[i][j]==a[l][c] && (i!=l && j!=c))
cont++;
}
}
} while(cont!=0);
}
}
for (int l=0;l<n;l++)
{
for (int c=0;c<n;c++)
{
printf(" \t %d ", a[l][c]);
}
printf("\n");
}
return 0;
}
But it didn’t work and I have no idea how to fix it.
includes which library?
– Maury Developer