DEV/BUT1/DEV1.1/Fonctions/1.txt

66 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2024-02-01 13:55:03 +01:00
#include <stdlib.h>
#include <stdio.h>
void triangle(void){
int h,x,y;
printf("hauteur ? ");
scanf("%d",&h);
for(x=0;x<=h;x++){
for(y=0;y<x;y++){
printf("*");
}
printf("\n");
}
printf("\n__________\n");
}
void carre(void){
int h,x,y;
printf("hauteur ? ");
scanf("%d",&h);
for(x=0;x<h;x++){
printf("*");
}
for(x=2;x<h;x++){
printf("\n*");
for(y=0;y<(h-2);y++){
printf(" ");
}
printf("*");
}
printf("\n");
for(x=0;x<h;x++){
printf("*");
}
printf("\n__________\n");
}
void quitter(void){
printf("au revoir...\n");
}
int main(void) {
/*X et Y c'est juste pour faire tourner les boucles => un compteur
le h c'est hauteur
le c c'est pour faire tourner une boule infini*/
int x,y,h,c;
char choix;
printf("t) Triangle\nc) Carré\nq) Quitter\nVotre choix : ");
scanf("%c",&choix);
for(c=0;c!=-1;c++){
if(choix == 't'){
triangle();
}
if(choix=='c'){
carre();
}
if(choix=='q'){
quitter();
return EXIT_SUCCESS;
}
printf("t) Triangle\nc) Carré\nq) Quitter\nVotre choix : ");
scanf(" %c",&choix);
}
return EXIT_SUCCESS;
}