Added macro variable for square width configuration in demo

This commit is contained in:
Dmitriy Shishkov 2021-12-19 12:53:39 +03:00
parent 3fcb562166
commit 78960fcbee
No known key found for this signature in database
GPG Key ID: 14358F96FCDD8060

View File

@ -40,7 +40,7 @@ std::string cp1251_to_utf8(const char* str)
return res; return res;
} }
#else #else
string str_of(unsigned k, const string input) { string str_of(unsigned k, const string& input) {
string res; string res;
for (;k > 0; k--) for (;k > 0; k--)
res += input; res += input;
@ -55,7 +55,7 @@ int main() {
string input, buff; string input, buff;
while(getline(cin, buff)) { while (getline(cin, buff)) {
input += buff + '\n'; input += buff + '\n';
} }
input.pop_back(); input.pop_back();
@ -68,19 +68,20 @@ int main() {
const auto& res = qr.to_vector(); const auto& res = qr.to_vector();
#define SQUARE_WIDTH 2
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
const string long_sep = string((res.size() + 8) * 2, 219), const string long_sep = string((res.size() + 8) * SQUARE_WIDTH, 219),
short_sep = string(4 * 2, 219), short_sep = string(4 * SQUARE_WIDTH, 219),
black = string(2, 219), black = string(SQUARE_WIDTH, 219),
white = " "; white = string(SQUARE_WIDTH, ' ');
SetConsoleCP(855); SetConsoleCP(855);
#else #else
const string long_sep = str_of((res.size() + 8) * 2, ""), const string long_sep = str_of((res.size() + 8) * SQUARE_WIDTH, ""),
short_sep = str_of(4 * 2, ""), short_sep = str_of(4 * SQUARE_WIDTH, ""),
black = str_of(2, ""), black = str_of(SQUARE_WIDTH, ""),
white = " "; white = string(SQUARE_WIDTH, ' ');
#endif #endif
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -104,4 +105,8 @@ int main() {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
cout << long_sep << endl; cout << long_sep << endl;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
system("pause");
#endif
} }