File tree 1 file changed +55
-0
lines changed
1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* Hacker Blocks */
2
+ /* Title - Pattern Double Sided Arrow */
3
+ // Take N as input. For a value of N=7, we wish to draw the following pattern :
4
+
5
+ // 1
6
+ // 2 1 1 2
7
+ // 3 2 1 1 2 3
8
+ // 4 3 2 1 1 2 3 4
9
+ // 3 2 1 1 2 3
10
+ // 2 1 1 2
11
+ // 1
12
+
13
+ #include < iostream>
14
+ using namespace std ;
15
+ int main () {
16
+ int n;
17
+ cin>>n;
18
+ for (int i=1 ;i<=(n+1 )/2 ;i++){
19
+ for (int j=1 ;j<=(2 *(n+1 -2 *i));j++){
20
+ cout<<" " ;
21
+ }
22
+ for (int j = i;j>0 ;j--){
23
+ cout<<j<<" " ;
24
+ }
25
+
26
+ for (int j=1 ;j<(4 *(i-1 )-1 );j++){
27
+ cout<<" " ;
28
+ }
29
+ if (i>1 ){
30
+ for (int j=1 ;j<=i;j++){
31
+ cout<<j<<" " ;
32
+ }
33
+ }
34
+ cout<<endl;
35
+ }
36
+ for (int i=n/2 ;i>0 ;i--){
37
+ for (int j=1 ;j<=(2 *(n+1 -2 *i));j++){
38
+ cout<<" " ;
39
+ }
40
+ for (int j = i;j>0 ;j--){
41
+ cout<<j<<" " ;
42
+ }
43
+
44
+ for (int j=1 ;j<(4 *(i-1 )-1 );j++){
45
+ cout<<" " ;
46
+ }
47
+ if (i>1 ){
48
+ for (int j=1 ;j<=i;j++){
49
+ cout<<j<<" " ;
50
+ }
51
+ }
52
+ cout<<endl;
53
+ }
54
+ return 0 ;
55
+ }
You can’t perform that action at this time.
0 commit comments