inittialisation du plateau à 0 avec des pommes placés aléatoirement
This commit is contained in:
@@ -5,13 +5,38 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
#define LIGNES 40
|
#define LIGNES 40
|
||||||
#define COLONNES 60
|
#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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user