-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctriangle.c
More file actions
43 lines (38 loc) · 786 Bytes
/
ctriangle.c
File metadata and controls
43 lines (38 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
int min(int a, int b) {
if(a < b)
return a;
else
return b;
}
int main(void) {
int x, y;
int base, hauteur;
printf("BASE => ");
scanf("%d", &base);
fflush(stdin);
if(base%2 == 0)
base++;
printf("HAUTEUR => ");
scanf("%d", &hauteur);
fflush(stdin);
printf("TRIANGLE: B=%d, H=%d\n", base, hauteur);
for (y=0; y < hauteur; y++) {
for (x=0; x < base; x++) {
if (y==0 && x==base/2)
printf(".");
else if (x==(base/2)-y)
printf("/");
else if (x==(base/2)+y)
printf("\\");
else if (y==min(base/2,hauteur-1) && \
x > (base/2)-y && \
x < (base/2)+y)
printf("_");
else
printf(" ");
}
printf("\n");
}
return 0;
}