Contrôle Machine
This commit is contained in:
parent
acd09bd426
commit
232ac45261
21
APL1.1/controle_machine/rangement.c
Normal file
21
APL1.1/controle_machine/rangement.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
unsigned long x = 6UL;
|
||||
|
||||
int y = 0x6;
|
||||
|
||||
double z = 6.0; /*On pourrait croire à tord d'utiliser un
|
||||
float mais il faut 'f' après le 6 pour en faire un float.*/
|
||||
|
||||
char w = '\66'; /* Les guillemets simples indiquent un caractère
|
||||
les guillemets doubles indiquent une chaine de caractères.*/
|
||||
|
||||
printf("%ld\n", x);
|
||||
printf("%d\n", y);
|
||||
printf("%f\n", z); //printf utilise '%f' pour les floats et les doubles
|
||||
printf("%c\n", w);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
19
APL1.1/controle_machine/regle.c
Normal file
19
APL1.1/controle_machine/regle.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
int taille;
|
||||
|
||||
printf("Entrez la longueur désirée (entre 1 et 9) : ");
|
||||
scanf("%d", &taille);
|
||||
|
||||
printf("|");
|
||||
for (int i = 0; i < taille; i++) printf("''''|''''|");
|
||||
|
||||
printf("\n0");
|
||||
for (int i = 0; i < taille; i++) printf(" %d", i+1);
|
||||
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
43
APL1.1/controle_machine/regression.c
Normal file
43
APL1.1/controle_machine/regression.c
Normal file
@ -0,0 +1,43 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<math.h>
|
||||
|
||||
#define POUCE 2.56
|
||||
#define PIED 30.72
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
int pieds = 0, pouces = 0;
|
||||
double taille;
|
||||
|
||||
printf("Veuillez indiquer votre taille : ");
|
||||
scanf("%lf", &taille);
|
||||
|
||||
taille *= 100;
|
||||
taille = (double)lround(taille);
|
||||
|
||||
while (taille >= PIED) {
|
||||
taille -= PIED;
|
||||
pieds++;
|
||||
}
|
||||
|
||||
while (taille >= POUCE) {
|
||||
taille -= POUCE;
|
||||
pouces++;
|
||||
}
|
||||
|
||||
|
||||
if (pieds > 0) {
|
||||
if (pouces > 0) {
|
||||
printf("Vous faites %d pied%s et %d pouce%s\n", pieds, pieds > 1 ? "s" : "",
|
||||
pouces, pouces > 1 ? "s" : "");
|
||||
} else {
|
||||
printf("Vous faites %d pied%s\n", pieds, pieds > 1 ? "s" : "");
|
||||
}
|
||||
|
||||
} else if (pouces > 0) {
|
||||
printf("Vous faites %d pouce%s\n", pouces, pouces > 1 ? "s" : "");
|
||||
} else printf("Vous faites moins d'un pouce !\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
44
APL1.1/controle_machine/reticule.c
Normal file
44
APL1.1/controle_machine/reticule.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
|
||||
int nb_square;
|
||||
|
||||
printf("Veuillez indiquer le nombre de carrés : ");
|
||||
scanf("%d", &nb_square);
|
||||
|
||||
|
||||
for (int i = 0; i < nb_square; i++) {
|
||||
for (int i2 = 0; i2 < i; i2++) printf("| ");
|
||||
|
||||
printf("+");
|
||||
for (int i2 = 0; i2 < ((nb_square-i)*2)-1; i2++) {
|
||||
printf("--");
|
||||
}
|
||||
printf("+");
|
||||
|
||||
|
||||
for (int i2 = 0; i2 < i; i2++) printf(" |");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < nb_square; i++) printf("| ");
|
||||
for (int i = 0; i < nb_square; i++) printf(" |");
|
||||
printf("\n");
|
||||
|
||||
for (int i = nb_square-1; i >= 0; i--) {
|
||||
for (int i2 = 0; i2 < i; i2++) printf("| ");
|
||||
|
||||
printf("+");
|
||||
for (int i2 = 0; i2 < ((nb_square-i)*2)-1; i2++) {
|
||||
printf("--");
|
||||
}
|
||||
printf("+");
|
||||
|
||||
|
||||
for (int i2 = 0; i2 < i; i2++) printf(" |");
|
||||
printf("\n");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
15
APL1.1/controle_machine/rongeur.c
Normal file
15
APL1.1/controle_machine/rongeur.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
puts(" (\\_/)");
|
||||
puts(" .-""-.-.-' a\\");
|
||||
puts(" / \\ _.--'");
|
||||
puts("(\\ /_---\\\\_\\_");
|
||||
puts(" `'-.");
|
||||
puts(" ,__)");
|
||||
|
||||
//Ne pas oublier de doubler tous les \ autrement il va y avoir des problèmes de formattage.
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user