Skip to content

Commit 26fc63c

Browse files
authored
Merge pull request #103 from gulshanlaskar08/master
double_sided_arrow_pattern
2 parents 93d3013 + 0b463f9 commit 26fc63c

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int n,k,l;
6+
cin>>n;
7+
int m=n/2;
8+
int a=n;
9+
if(n%2 != 0)
10+
{
11+
for(int i=1; i<=((n/2) + 1);i++)
12+
{
13+
k=i;
14+
15+
//outer left space
16+
17+
for(int j=n/2;j>=i;j--)
18+
{
19+
cout<<" ";
20+
}
21+
22+
//no.s
23+
24+
for(int j=1;j<=i;j++)
25+
{
26+
cout<<k<<" ";
27+
k--;
28+
}
29+
30+
//inner space
31+
32+
for(int j=1;j<i;j++)
33+
{
34+
cout<<" ";
35+
}
36+
for(int j = 2;j<i;j++)
37+
{
38+
cout<<" ";
39+
}
40+
41+
//riht side no.s
42+
if(i != 1)
43+
{
44+
l = 1;
45+
for(int j=0;j<i;j++)
46+
{
47+
cout<<l<<" ";
48+
l++;
49+
}
50+
}
51+
52+
cout<<endl;
53+
}
54+
//lower part
55+
for(int i=1;i<=n/2;i++)
56+
{
57+
int x=1;
58+
//lower left corner space
59+
for(int j=0;j<i;j++)
60+
{
61+
cout<<" ";
62+
}
63+
64+
//numbers
65+
for(int j=m;j>0;j--)
66+
{
67+
if(j!=1)
68+
{cout<<j<<" ";}
69+
else
70+
{cout<<j;}
71+
}
72+
m--;
73+
//inner space
74+
75+
for(int j=1;j<=a;j++)
76+
{
77+
if(i!=n/2)
78+
{cout<<" ";}
79+
}
80+
a -= 2;
81+
82+
//numbers
83+
84+
for(int j=n/2 + 1;j>i;j--)
85+
{
86+
if(i!=n/2)
87+
{
88+
cout<<x<<" ";
89+
x++;
90+
}
91+
}
92+
93+
cout<<endl;
94+
}
95+
96+
}
97+
98+
99+
return 0;
100+
}

0 commit comments

Comments
 (0)