-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB219043_Lab04_15.c
More file actions
52 lines (52 loc) · 1.01 KB
/
B219043_Lab04_15.c
File metadata and controls
52 lines (52 loc) · 1.01 KB
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
44
45
46
47
48
49
50
51
52
#include<stdio.h>
void pyramid(int);
void pyramidr(int);
int main(void)
{
printf("Enter an odd number height\t");
int h;
scanf("%d",&h);
if (h%2==0)
{
printf("Enter an odd number kiddo");
return 0;
}
h=(h+1)/2;
pyramid(h);
pyramidr(h);
return 0;
}
void pyramid(int h)
{
for (int i=h;i>=1;i--)
{
for(int j=1;j<=i;j++)
printf("@ ");
for(int j=1;j<=(h-i)*2-1;j++)
printf(" ");
for(int j=1;j<=i;j++)
{
if (j==1 && i==h)
continue;
printf("@ ");
}
printf("\n");
}
}
void pyramidr(int h)
{
for (int i=2;i<=h;i++)
{
for(int j=1;j<=i;j++)
printf("@ ");
for(int j=1;j<=(h-i)*2-1;j++)
printf(" ");
for(int j=1;j<=i;j++)
{
if (j==1 && i==h)
continue;
printf("@ ");
}
printf("\n");
}
}