-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_4_hash_shape.cpp
99 lines (83 loc) · 1.97 KB
/
2_4_hash_shape.cpp
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
#include <sstream>
#include <iostream>
#include <iomanip>
/*
Hash shape by using only single cout functions.
*/
using std::cin;
using std::cout;
using std::endl;
using std::setw;
int main()
{
enum lr {LEFT, RIGHT, NEXT};
enum part {UPPER, MIDDLE, BELT, BOTTOM};
int starSizeParam = 40;
int change = 2;
int space = 5;
int indent = 3.1*starSizeParam/2-1;
int indentChange = -1;
int spaceChange = 8;
int extraIndent = 4;
int pos = LEFT;
int part = UPPER;
for (int hashWidth=2; hashWidth > 0; hashWidth+=change)
{
pos = LEFT;
cout << part;
while (pos != NEXT)
{
if (pos == LEFT)
{
cout << setw(indent+extraIndent);
indent += indentChange;
}
else
{
cout << setw(space);
space += spaceChange;
}
for (int hashNum = 0; hashNum < hashWidth; hashNum++)
{
cout << "#";
}
if (part == BOTTOM)
{
pos = ++pos % 3;
}
else
{
pos = NEXT;
}
if (pos == NEXT)
{
cout << "\n";
}
}
if (hashWidth >= starSizeParam && part == UPPER)
{
change = -4;
hashWidth = 3.1*starSizeParam;
indent = 1;
indentChange = 2;
part = MIDDLE;
}
else if (hashWidth <= (1.8*starSizeParam) && part == MIDDLE)
{
hashWidth = hashWidth-4;
change = 2;
indentChange = -1;
indent -= 1;
part = BELT;
}
else if (hashWidth >= (2*starSizeParam) && part == BELT)
{
hashWidth = hashWidth/2+2;
change = -3;
indentChange = -1;
part = BOTTOM;
}
}
cin.get();
return 0;
}