-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPattern-HourGlass.cpp
More file actions
79 lines (62 loc) · 955 Bytes
/
Pattern-HourGlass.cpp
File metadata and controls
79 lines (62 loc) · 955 Bytes
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
#include <iostream>
using namespace std;
/*
5 4 3 2 1 0 1 2 3 4 5
4 3 2 1 0 1 2 3 4
3 2 1 0 1 2 3
2 1 0 1 2
1 0 1
0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
5 4 3 2 1 0 1 2 3 4 5
*/
int main(){
int N=12;
for (int i = 1; i <= N; i++)
{
// UPPER PART
// SPACES
for (int s = 1; s <= 2*i-2; s++)
{
cout<<" ";
}
// NUMBERS
for (int j = N-i+1; j >=0 ; j--)
{
cout<<j<<" ";
}
for (int k = 1; k <= N-i+1 ; k++)
{
cout<<k<<" ";
}
cout<<endl;
}
for (int i = 0; i <= N*2-1 ; i++)
{
cout<<" ";
}
cout<<"0"<<" "<<endl;;
for (int i = N; i >= 1; i--)
{
// LOWER PART
// SPACES
for (int s = 1; s <= 2*i-2; s++)
{
cout<<" ";
}
// NUMBERS
for (int j = N-i+1; j >=0 ; j--)
{
cout<<j<<" ";
}
for (int k = 1; k <= N-i+1 ; k++)
{
cout<<k<<" ";
}
cout<<endl;
}
return 0;
}