From deed4ef7a3a92c74324b33168362e8bb36523e5e Mon Sep 17 00:00:00 2001 From: Axel Date: Mon, 28 Nov 2022 08:59:59 +0100 Subject: [PATCH] =?UTF-8?q?Tests=20de=20g=C3=A9n=C3=A9ration=20de=20grille?= =?UTF-8?q?=20de=20paires=20al=C3=A9atoires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grille.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 grille.c diff --git a/grille.c b/grille.c new file mode 100644 index 0000000..6317c2d --- /dev/null +++ b/grille.c @@ -0,0 +1,29 @@ +#include +#include +#include + +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; +} + +