-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpalindromic pyramid.txt
52 lines (46 loc) · 1.08 KB
/
palindromic pyramid.txt
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>
int main(){
printf("Enter a value to print a palindrome pyramid \n");
int inp1;
scanf("%d",&inp1);
printf("*\n*");
for(int i=1;i<=inp1;i++){
for(int w=1;w<i;w++){
if(w==1){
printf("*%d",w);
}
else{
printf("%d",w);
}
}
for(int r=i;r>=1;r--){
if(r==1){
printf("%d*",r);
}
else{
printf("%d",r);
}
}
printf("\n");
}
for(int j=inp1-1;j>=1;j--){
for(int w=1;w<=j;w++){
if(w==1){
printf("*%d",w);
}
else{
printf("%d",w);
}
}
for(int r=j-1;r>=1;r--){
if(r==1){
printf("%d*",r);
}
else{
printf("%d",r);
}
if (j!=1){
printf("\n");}
}
printf("*\n*");
}