-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinting_pyramid.c
46 lines (41 loc) · 1012 Bytes
/
printing_pyramid.c
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
/******************************************************************************
Program for printing pyramids surrounded by 1's eg 1
121
1
*******************************************************************************/
#include <stdio.h>
int main()
{
int i,j,k,l,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=0;j<n-i;j++)
{
printf(" ");
}
for(k=1;k<=i;k++){
printf("%d",k);
}
for(l=i-1;l>=1;l--)
{
printf("%d",l);
}
printf("\n");
}
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=1;k<=n-i;k++){
printf("%d",k);
}
for(l=n-i-1;l>=1;l--)
{
printf("%d",l);
}
printf("\n");
}
}