Contrôle Machine Blanc
This commit is contained in:
parent
307a131abe
commit
2dc604867e
35
APL1.1/CMB1/distribution.c
Normal file
35
APL1.1/CMB1/distribution.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<time.h>
|
||||
|
||||
#define NB_RANGEES 15
|
||||
#define NB_BILLES 150
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
srand(time(NULL));
|
||||
|
||||
int colonnes[NB_RANGEES] = {};
|
||||
|
||||
for (int essai = 0; essai < NB_BILLES; essai++) { //On simule le nombre de billes.
|
||||
int colonne_bille = NB_RANGEES - 1; //On fait commencer la bille a la colonne du milieu (-1 afin de simplifier l'insertion dans le tableau).
|
||||
|
||||
for (int rangee = 0; rangee < NB_RANGEES; rangee++) {
|
||||
//On simule chaque rangée et ou la bille va-elle aller.
|
||||
srand(rand());
|
||||
int choix = rand() % 2;
|
||||
|
||||
if (choix == 0) colonne_bille++; //Si le nombre aléatoire est pair alors on va à droite.
|
||||
else colonne_bille--; //Sinon on va à gauche.
|
||||
}
|
||||
|
||||
colonnes[colonne_bille/2]++; //On divise la valeur de résultat par 2 pour mettre deux colonnes dans un seul bac (tel le schéma de l'énoncé).
|
||||
}
|
||||
|
||||
for (int i = 0; i < NB_RANGEES; i++) { //On créer l'histogramme
|
||||
for (int count = 0; count < colonnes[i]; count++) printf("▄");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
24
APL1.1/CMB1/histogramme.c
Normal file
24
APL1.1/CMB1/histogramme.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<time.h>
|
||||
|
||||
#define SIZE_TABLE 20
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
|
||||
int table[SIZE_TABLE] = {};
|
||||
|
||||
srand(time(NULL));
|
||||
for (int i = 0; i < SIZE_TABLE; i++) { //On génère les valeurs aléatoires
|
||||
srand(rand());
|
||||
table[i] = rand() % 21;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SIZE_TABLE; i++) { //On créer l'histogramme
|
||||
for (int count = 0; count < table[i]; count++) printf("▄");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
22
APL1.1/CMB1/parite.c
Normal file
22
APL1.1/CMB1/parite.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
int x, y;
|
||||
|
||||
printf("Entrez le premier entier : ");
|
||||
scanf("%d", &x);
|
||||
printf("Entrez le deuxième entier : ");
|
||||
scanf("%d", &y);
|
||||
|
||||
int x_pair = x % 2 == 0, y_pair = y % 2 == 0;
|
||||
|
||||
if ((x_pair && y_pair) || (x_pair && !y_pair) || (!x_pair && y_pair)) {
|
||||
puts("Pair");
|
||||
} else {
|
||||
puts("Impair");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
10
APL1.1/CMB1/rapace.c
Normal file
10
APL1.1/CMB1/rapace.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
puts(" {o,o}");
|
||||
puts(" (__(\\");
|
||||
puts(" -\"-\"-");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
16
APL1.1/CMB1/triage.c
Normal file
16
APL1.1/CMB1/triage.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
double a = 2.0;
|
||||
int b = 02;
|
||||
char c = 0x32;
|
||||
long d = 2L;
|
||||
|
||||
printf("%1.0f\n", a);
|
||||
printf("%d\n", b);
|
||||
printf("%c\n", c);
|
||||
printf("%ld\n", d);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user