I'd like to produce a 6x6 matrix by inserting random numbers to the elements in the row and column without repeating. This is my code so far. Thank you for your help!
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int array[6][6];
int rows, columns;
int random;
srand((unsigned)time(NULL));
for(rows=0;rows<6;rows++)
{
for(columns=0;columns<6;columns++)
{
random=rand()%36+1;
array[rows][columns] = random;
printf("%i",array[rows][columns]);
}
printf("\n");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire