Tests de génération de grille de paires aléatoires
This commit is contained in:
parent
1b2212f447
commit
deed4ef7a3
29
grille.c
Normal file
29
grille.c
Normal 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user