64 lines
941 B
C
64 lines
941 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <time.h>
|
||
|
#define ETAGES 4
|
||
|
#define NBRBILLES 10
|
||
|
|
||
|
int main (void) {
|
||
|
|
||
|
int i,y,z,compteur=0,direction,trou,comptg,comptd;
|
||
|
int resultats[NBRBILLES];
|
||
|
|
||
|
srand(time(NULL));
|
||
|
|
||
|
for(y=0; y<NBRBILLES; y++){
|
||
|
trou=3;
|
||
|
comptg=1;
|
||
|
comptd=0;
|
||
|
for(i=0; i<ETAGES; i++){
|
||
|
direction=rand()%2;
|
||
|
if(direction==0){
|
||
|
if(comptg==1){
|
||
|
trou--;
|
||
|
comptg--;
|
||
|
comptd++;
|
||
|
} else {
|
||
|
comptg++;
|
||
|
comptd--;
|
||
|
}
|
||
|
}
|
||
|
if (direction==1){
|
||
|
if(comptd==1){
|
||
|
trou++;
|
||
|
comptg++;
|
||
|
comptd--;
|
||
|
} else {
|
||
|
comptd++;
|
||
|
comptg--;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
resultats[y]=trou;
|
||
|
}
|
||
|
|
||
|
for(y=0; y<5; y++){
|
||
|
for (z=0; z<NBRBILLES; z++){
|
||
|
if(resultats[z]==y+1){
|
||
|
compteur++;
|
||
|
}
|
||
|
}
|
||
|
printf("\nBilles tombées dans le trou %d : ", y+1);
|
||
|
for (i=0; i<compteur; i++){
|
||
|
printf("▄");
|
||
|
}
|
||
|
//printf("%d\n", compteur); //pour vérif
|
||
|
compteur=0;
|
||
|
printf("\n");
|
||
|
|
||
|
}
|
||
|
|
||
|
printf("\n");
|
||
|
|
||
|
|
||
|
}
|