DEbut TP08
This commit is contained in:
31
DEV1.1/TP08/figures.c
Normal file
31
DEV1.1/TP08/figures.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int hauteur_carre,etage,espace,forme,tour_etage,tour_etoile;
|
||||
printf("t) Triangle \nc)Carré \nq)Quitter\n");
|
||||
scanf("%c",&forme);
|
||||
printf("Donnez un entier pour le nombre d'étage : ");
|
||||
scanf("%d",&etage);
|
||||
if (forme=='q')
|
||||
printf("Au revoir ...\n");
|
||||
else if (forme=='c') {
|
||||
for (tour_etoile=0;tour_etoile<etage;tour_etoile++){
|
||||
printf("* ");
|
||||
for (hauteur_carre=0;hauteur_carre<(etage-2);hauteur_carre++){
|
||||
for (espace=0;espace<(espace/2);espace++){
|
||||
printf(" ");
|
||||
}
|
||||
for (tour_etage=0;tour_etage<etage;tour_etage++){
|
||||
for (tour_espace=0;tour_espace<(espace/2);tour_espace++){
|
||||
printf(" ");
|
||||
}
|
||||
for (tour_etoile=0;tour_etoile<nbr_etoile;tour_etoile++){
|
||||
printf("*");
|
||||
}
|
||||
printf("\n");
|
||||
nbr_etoile+=2;
|
||||
espace-=2;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
BIN
DEV1.1/TP08/sapin
Executable file
BIN
DEV1.1/TP08/sapin
Executable file
Binary file not shown.
21
DEV1.1/TP08/sapin.c
Normal file
21
DEV1.1/TP08/sapin.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int nbr_etoile=1,etage,espace,tour_etage,tour_espace,tour_etoile;
|
||||
printf("Donnez un entier pour le nombre d'étage : ");
|
||||
scanf("%d",&etage);
|
||||
espace=(etage-1)*2;
|
||||
for (tour_etage=0;tour_etage<etage;tour_etage++){
|
||||
for (tour_espace=0;tour_espace<(espace/2);tour_espace++){
|
||||
printf(" ");
|
||||
}
|
||||
for (tour_etoile=0;tour_etoile<nbr_etoile;tour_etoile++){
|
||||
printf("*");
|
||||
}
|
||||
printf("\n");
|
||||
nbr_etoile+=2;
|
||||
espace-=2;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user