Tests de génération de grille de paires aléatoires

This commit is contained in:
Axel PIETROIS 2022-11-28 08:59:59 +01:00
parent 1b2212f447
commit deed4ef7a3

29
grille.c Normal file
View File

@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int* grille(int taille) {
srand(time(NULL));
int i,j;
int coos[2];
int tab[taille][taille] = {};
coos[0] = rand()%taille;
coos[1] = rand()%taille;
for (i=0;i<6;i++){
for (j=0;j<6;j++){
tab[i][j] = -1;
}
}
for (i=0;i<18;i++){
for (j=0;j<2;j++){
while (tab[coos[0]][coos[1]] != -1){
coos[0] = rand()%6;
coos[1] = rand()%6;
}
tab[coos[0]][coos[1]] = i;
}
}
return tab;
}