Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- author: Asif Anwar Sajid
- */
- #include <bits/stdc++.h>
- #define pb push_back
- #define ll long long
- #define F first
- #define S second
- using namespace std;
- void c_p_c()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- bool upHr(int n)
- {
- if (n == 0 || n == 2 || n == 3 || (n >= 5 && n <= 9)) return true;
- return false;
- }
- bool upVerL(int n)
- {
- if (n == 0 || n == 4 || n == 5 || n == 6 || n == 8 || n == 9) return true;
- return false;
- }
- bool upVerR(int n)
- {
- if ((n >= 0 && n <= 4) || (n >= 7 && n <= 9)) return true;
- return false;
- }
- bool midHr(int n)
- {
- if ((n >= 2 && n <= 6) || n == 8 || n == 9) return true;
- return false;
- }
- bool botVerL(int n)
- {
- if (n == 0 || n == 2 || n == 6 || n == 8) return true;
- return false;
- }
- bool botVerR(int n)
- {
- if (n == 0 || n == 1 || (n >= 3 && n <= 9)) return true;
- return false;
- }
- bool botHr(int n)
- {
- if (n == 1 || n == 4 || n == 7) return false;
- return true;
- }
- void solve()
- {
- int s, n;
- int xyz = 0;
- while (cin >> s >> n) {
- if (xyz) cout << endl;
- if (s == 0 && n == 0) return;
- char arr[500][500];
- memset(arr, ' ', sizeof(arr));
- //int temp = n;
- int tt2 = n;
- string str;
- if (n == 0) str += '0';
- while (tt2 > 0) {
- char ch = (char)((tt2 % 10) + '0');
- tt2 /= 10;
- str += ch;
- }
- int sz = str.size();
- reverse(str.begin(), str.end());
- int cnt = 0;
- int zz = 0;
- while (zz < sz) {
- int rem = (int)(str[zz] - '0');
- if (upHr(rem)) {
- int row = 0;
- int shuru = cnt * (s + 2) + (cnt + 1);
- int end = shuru + s;
- for (int i = shuru; i < end; i++) {
- arr[row][i] = '-';
- }
- }
- if (upVerL(rem)) {
- int col = cnt * (s + 2) + cnt;
- int shuru = 1;
- int end = s + shuru;
- for (int i = shuru; i < end; i++) {
- arr[i][col] = '|';
- }
- }
- if (upVerR(rem)) {
- int col = cnt * (s + 2) + cnt + s + 1;
- int shuru = 1;
- int end = s + shuru;
- for (int i = shuru; i < end; i++) {
- arr[i][col] = '|';
- }
- }
- if (midHr(rem)) {
- int row = s + 1;
- int shuru = cnt * (s + 2) + (cnt + 1);
- int end = shuru + s;
- for (int i = shuru; i < end; i++) {
- arr[row][i] = '-';
- }
- }
- if (botVerL(rem)) {
- int col = cnt * (s + 2) + cnt;
- int shuru = 2 + s;
- int end = shuru + s;
- for (int i = shuru; i < end; i++) {
- arr[i][col] = '|';
- }
- }
- if (botVerR(rem)) {
- int col = cnt * (s + 2) + cnt + s + 1;
- int shuru = 2 + s;
- int end = shuru + s;
- for (int i = shuru; i < end; i++) {
- arr[i][col] = '|';
- }
- }
- if (botHr(rem)) {
- int row = 2 * s + 2;
- int shuru = cnt * (s + 2) + (cnt + 1);
- int end = shuru + s;
- for (int i = shuru; i < end; i++) {
- arr[row][i] = '-';
- }
- }
- cnt++;
- zz++;
- }
- for (int i = 0; i < (2 * s + 3); i++) {
- for (int j = 0; j < (cnt * (s + 2) + cnt) - 1; j++) {
- cout << arr[i][j];
- }
- cout << endl;
- }
- xyz++;
- }
- }
- int main()
- {
- c_p_c();
- //FastIO;
- //freopen("tttt.in", "r", stdin);
- //freopen("tttt.out", "w", stdout);
- int t = 1;
- //cin >> t;
- while (t--)
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement