-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sand Hour Glass in C++.cpp
138 lines (102 loc) · 1.46 KB
/
Sand Hour Glass in C++.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include<iostream>
#include<windows.h>
#include<string>
using namespace std;
void setCord(int x, int y)
{
COORD c = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void main()
{
int t, w, k, j, q, tp;
char c;
cout << "Enter the number of seconds:";
cin >> t;
w = 2 * t;
int w2 = 2 * t;
k = t + 2;
k = t - k;
k = k + 1;
tp = t - 1;
cout << "Enter the Character to represent sand:";
cin >> c;
for (int i = 0; i <= t; i++)
{
for (j = 1; j <= i; j++)
{
cout << " ";
}
if (i == 0)
{
cout << " ";
for (int i = 0; i <= w2; i++)
{
cout << "_";
}
}
if (i != 0)
{
cout << "\\";
for (int k = 1; k < w; k++)
{
cout << c;
}
w = w - 2;
cout << "/";
}
cout << endl;
}
q = j - 1;
w = 0;
// Part 2
for (int i = 0; i <= t; i++)
{
for (j = q; j > i; j--)
{
cout << " ";
}
if (i == t)
{
cout << " ";
for (int i = 0; i <= w2; i++)
{
cout << "_";
}
}
if (i != t)
{
cout << "/";
for (int k = w; k >= 0; k--)
{
cout << "-";
}
w = w + 2;
cout << "\\";
}
cout << endl;
}
int x1 = 2, y1 = 3;
int x2 = 2, y2 = (t * 2) + 2;
// New
for (int p = 0; p <= tp; p++)
{
setCord(x1, y1);
for (int j = 1; j < w2; j++)
{
cout << " ";
}
x1++;
y1++;
Sleep(750);
setCord(x2, y2);
for (int j = 1; j < w2; j++)
{
cout << c;
}
w2 = w2 - 2;;
x2++; y2--;
}
setCord(0, 0);
system("pause");
}