DEV/DEV1.1/TP10:Fonctions/decoupage.c

66 lines
1.0 KiB
C
Raw Permalink Normal View History

2022-11-09 17:12:39 +01:00
#include <stdio.h>
#include <stdlib.h>
void triangle(int h) {
int i;
int j;
int e;
for (i=0;i<=h;i++){
for (j=h-i;j>0;j--){
} for (e=0;e<i;e++){
printf("*");
} printf("\n");
}
}
void carre(int h){
int i;
int j;
for (i=1;i<=h;i++){
for (j=1;j<=h;j++){
if (j==1||j==h){
printf("* ");
} else{
if (i==1||i==h){
printf("* ");
}else{
printf(" ");
}
}
}printf("\n");
}
}
char menu() {
char n;
printf("_______________\nt) Triangle\nc) Carre\nq) Quitter\nVotre choix ? ");
scanf(" %c",&n);
return n;
}
int main() {
int z=0;
int h;
char c;
while(z==0){
c=menu();
if (c=='t'){
printf("Hauteur ? ");
scanf("%d",&h);
triangle(h);
} else {
if (c=='c'){
printf("Hauteur ? ");
scanf("%d",&h);
carre(h);
} else{
if(c=='q'){
printf("Au revoir...\n\n");
break;
}
}
}
}
return 0;
}