From 7c7c3957218ae02cb88ec5e191f8119f8257a66b Mon Sep 17 00:00:00 2001 From: keraudre Date: Thu, 23 Nov 2023 11:13:25 +0100 Subject: [PATCH] =?UTF-8?q?inittialisation=20du=20plateau=20=C3=A0=200=20a?= =?UTF-8?q?vec=20des=20pommes=20plac=C3=A9s=20al=C3=A9atoirement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prog/plateau.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/prog/plateau.c b/prog/plateau.c index e68ad89..a901597 100644 --- a/prog/plateau.c +++ b/prog/plateau.c @@ -5,13 +5,38 @@ #include #include +#include #define LIGNES 40 #define COLONNES 60 +#define NBR_POMME 5 -int* plateau(void) { +int main(void) { - int tableau[LIGNES][COLONNES]; + int tableau[LIGNES][COLONNES] = {0}, ligne_pomme, colonne_pomme, indice, indice2, compteur = 0 ; + srand(time(NULL)); + + for ( indice = 0; indice < NBR_POMME; indice++) { + - return tableau; + ligne_pomme = rand() % 60; + colonne_pomme = rand() % 60; + + compteur += 1; + + tableau[ligne_pomme][colonne_pomme] = 2; + + } + + for ( indice = 0; indice < LIGNES; indice++) { + + for ( indice2 = 0; indice2 < COLONNES; indice2++) { + + printf("%d", tableau[indice][indice2]); + + } + } + printf("\n%d", compteur); + + return EXIT_SUCCESS; }