-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyramide.cpp
134 lines (121 loc) · 2.59 KB
/
Pyramide.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
using namespace std;
#include <iostream>
#include <windows.h>
#include <cstdlib>
// normal pyramides
int stpath(int s_am) {
for (int i = 1; i <= s_am; i++)
{
cout << std::string(i, '-') << endl;
if (i == s_am) {
cout << std::string(s_am + 1, '-') << endl;
}
}
return true;
}
int ndpath(int s_am) {
for (int i = s_am; i >= 0; i--)
{
cout << std::string(i, '-') << endl;
}
return true;
}
// inverted pyramides
int inv_stpath(int s_am) {
int g = 1;
for (int i = s_am; i > 0; i--)
{
cout << std::string(i, ' ') << std::string(g, '-') << endl;
g++;
if (g == s_am + 1) {
cout << std::string(s_am + 1, '-') << endl;
}
}
return true;
}
int inv_ndpath(int s_am) {
int g = s_am;
for (int i = 1; i <= s_am; i++)
{
cout << std::string(i, ' ') << std::string(g, '-') << endl;
g--;
if (g == s_am + 1) {
cout << std::string(s_am + 1, '-') << endl;
}
}
cout << endl;
return true;
}
int hello() {
string inp = " meow soft";
int i = 0;
while (i <= inp.length()){
cout << inp[i];
i++;
Sleep(100);
if (i == inp.length()) {
cout << endl;
cout << std::string(11, '-');
cout << endl;
}
}
return 1;
}
// main code
int main() {
hello();
setlocale(LC_ALL, "Russian");
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
int i = 1;
int select;
string str;
int fail_counter = 0;
cout << "Укажите высоту пирамид: ";
cin >> select;
while (cin.fail()) {
SetConsoleTextAttribute(hConsole, 12);
if (fail_counter <= 5) {
cout << "Число введи, гений" << std::endl;
cin.clear();
cin.ignore(256, '\n');
cin >> select;
}
else if( fail_counter <= 10) {
cout << "Ты можешь хотя бы с " << fail_counter << " раза написать число?" << std::endl;
cin.clear();
cin.ignore(256, '\n');
cin >> select;
}
else {
cout << "пшёл вон";
Sleep(100);
exit(1);
}
fail_counter++;
}
while (true)
{
for (int z = 1; z < 10; z++) {
SetConsoleTextAttribute(hConsole, z);
cout << std::string(20, '-') << endl << " \t" << i << endl << std::string(20, '-') << endl << endl;
stpath(select);
ndpath(select);
inv_stpath(select);
inv_ndpath(select);
Sleep(80);
i++;
if (i == 100) {
cout << endl << "Чего ты ждёшь?" <<endl;
}
if (i == 200) {
cout << endl << "Тут ничего нет, и на 500 тоже" << endl;
}
if (i == 500) {
cout << endl << "Мяу. На 1000 точно ничего нет" << endl;
}
if (i == 1000) {
cout << endl << "Я же говорил, тут ничего нет." << endl;
}
}
}
}