forked from larissalages/code_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdouble_sided_arrow_pattern.cpp
More file actions
100 lines (84 loc) · 1.6 KB
/
double_sided_arrow_pattern.cpp
File metadata and controls
100 lines (84 loc) · 1.6 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include<iostream>
using namespace std;
int main()
{
int n,k,l;
cin>>n;
int m=n/2;
int a=n;
if(n%2 != 0)
{
for(int i=1; i<=((n/2) + 1);i++)
{
k=i;
//outer left space
for(int j=n/2;j>=i;j--)
{
cout<<" ";
}
//no.s
for(int j=1;j<=i;j++)
{
cout<<k<<" ";
k--;
}
//inner space
for(int j=1;j<i;j++)
{
cout<<" ";
}
for(int j = 2;j<i;j++)
{
cout<<" ";
}
//riht side no.s
if(i != 1)
{
l = 1;
for(int j=0;j<i;j++)
{
cout<<l<<" ";
l++;
}
}
cout<<endl;
}
//lower part
for(int i=1;i<=n/2;i++)
{
int x=1;
//lower left corner space
for(int j=0;j<i;j++)
{
cout<<" ";
}
//numbers
for(int j=m;j>0;j--)
{
if(j!=1)
{cout<<j<<" ";}
else
{cout<<j;}
}
m--;
//inner space
for(int j=1;j<=a;j++)
{
if(i!=n/2)
{cout<<" ";}
}
a -= 2;
//numbers
for(int j=n/2 + 1;j>i;j--)
{
if(i!=n/2)
{
cout<<x<<" ";
x++;
}
}
cout<<endl;
}
}
return 0;
}