Created
July 17, 2020 13:52
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <set> | |
#include <map> | |
#include <iostream> | |
using namespace std; | |
int main() { | |
int s; | |
string n; | |
map<int, set<int>> lines = { { 0, { 2, 3, 5, 6, 7, 8, 9, 0 } }, | |
{ 1, { 4, 5, 6, 8, 9, 0 } }, | |
{ 2, { 1, 2, 3, 4, 7, 8, 9, 0 } }, | |
{ 3, { 2, 3, 4, 5, 6, 8, 9 } }, | |
{ 4, { 2, 6, 8, 0 } }, | |
{ 5, { 1, 3, 4, 5, 6, 7, 8, 9, 0 } }, | |
{ 6, { 2, 3, 5, 6, 8, 9, 0 } } }; | |
while (cin >> s >> n) { | |
if (s == 0 && n == "0") | |
break; | |
int width = (s + 3) * n.size() - 1; | |
int height = 2 * s + 3; | |
for (int j = 0; j < height; ++j) { | |
// clang-format off | |
int y = j == 0 ? 0 | |
: j <= s ? 1 | |
: j == s + 1 ? 2 | |
: j <= 2 * s + 1 ? 3 | |
: 4; | |
// clang-format on | |
for (int i = 0; i < width; ++i) { | |
int x_ = i % (s + 3); | |
// clang-format off | |
int x = x_ == 0 ? 0 | |
: x_ <= s ? 1 | |
: x_ == s + 1 ? 2 | |
: 3; | |
// clang-format on | |
int d = n[i / (s + 3)] - '0'; | |
if (false) | |
; | |
#define P(a, b, c, t) \ | |
else if (x == a && y == b && lines[c].find(d) != lines[c].end()) cout << t | |
P(1, 0, 0, '-'); | |
P(0, 1, 1, '|'); | |
P(2, 1, 2, '|'); | |
P(1, 2, 3, '-'); | |
P(0, 3, 4, '|'); | |
P(2, 3, 5, '|'); | |
P(1, 4, 6, '-'); | |
#undef P | |
else cout << ' '; | |
} | |
cout << '\n'; | |
} | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment