Advertisement
Asif_Anwar

UVa problem: 706 - LC-Display

Mar 7th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.16 KB | None | 0 0
  1. /*
  2.     author: Asif Anwar Sajid
  3. */
  4.  
  5. #include <bits/stdc++.h>
  6. #define pb push_back
  7. #define ll long long
  8. #define F first
  9. #define S second
  10. using namespace std;
  11. void c_p_c()
  12. {
  13.     ios_base::sync_with_stdio(0);
  14.     cin.tie(0);
  15.     cout.tie(0);
  16. #ifndef ONLINE_JUDGE
  17.     freopen("input.txt", "r", stdin);
  18.     freopen("output.txt", "w", stdout);
  19. #endif
  20. }
  21.  
  22. bool upHr(int n)
  23. {
  24.     if (n == 0 || n == 2 || n == 3 || (n >= 5 && n <= 9)) return true;
  25.     return false;
  26. }
  27. bool upVerL(int n)
  28. {
  29.     if (n == 0 || n == 4 || n == 5 || n == 6 || n == 8 || n == 9) return true;
  30.     return false;
  31. }
  32. bool upVerR(int n)
  33. {
  34.     if ((n >= 0 && n <= 4) || (n >= 7 && n <= 9)) return true;
  35.     return false;
  36. }
  37. bool midHr(int n)
  38. {
  39.     if ((n >= 2 && n <= 6) || n == 8 || n == 9) return true;
  40.     return false;
  41. }
  42.  
  43. bool botVerL(int n)
  44. {
  45.     if (n == 0 || n == 2 || n == 6 || n == 8) return true;
  46.     return false;
  47. }
  48.  
  49. bool botVerR(int n)
  50. {
  51.     if (n == 0 || n == 1 || (n >= 3 && n <= 9)) return true;
  52.     return false;
  53. }
  54.  
  55. bool botHr(int n)
  56. {
  57.     if (n == 1 || n == 4 || n == 7) return false;
  58.     return true;
  59. }
  60.  
  61. void solve()
  62. {
  63.     int s, n;
  64.     int xyz = 0;
  65.     while (cin >> s >> n) {
  66.         if (xyz) cout << endl;
  67.         if (s == 0 && n == 0) return;
  68.         char arr[500][500];
  69.         memset(arr, ' ', sizeof(arr));
  70.         //int temp = n;
  71.         int tt2 = n;
  72.         string str;
  73.         if (n == 0) str += '0';
  74.         while (tt2 > 0) {
  75.             char ch = (char)((tt2 % 10) + '0');
  76.             tt2 /= 10;
  77.             str += ch;
  78.         }
  79.         int sz = str.size();
  80.         reverse(str.begin(), str.end());
  81.         int cnt = 0;
  82.         int zz = 0;
  83.         while (zz < sz) {
  84.             int rem = (int)(str[zz] - '0');
  85.             if (upHr(rem)) {
  86.                 int row = 0;
  87.                 int shuru = cnt * (s + 2) + (cnt + 1);
  88.                 int end = shuru + s;
  89.                 for (int i = shuru; i < end; i++) {
  90.                     arr[row][i] = '-';
  91.                 }
  92.             }
  93.             if (upVerL(rem)) {
  94.                 int col = cnt * (s + 2) + cnt;
  95.                 int shuru = 1;
  96.                 int end = s + shuru;
  97.                 for (int i = shuru; i < end; i++) {
  98.                     arr[i][col] = '|';
  99.                 }
  100.             }
  101.             if (upVerR(rem)) {
  102.                 int col = cnt * (s + 2) + cnt + s + 1;
  103.                 int shuru = 1;
  104.                 int end = s + shuru;
  105.                 for (int i = shuru; i < end; i++) {
  106.                     arr[i][col] = '|';
  107.                 }
  108.             }
  109.             if (midHr(rem)) {
  110.                 int row = s + 1;
  111.                 int shuru = cnt * (s + 2) + (cnt + 1);
  112.                 int end = shuru + s;
  113.                 for (int i = shuru; i < end; i++) {
  114.                     arr[row][i] = '-';
  115.                 }
  116.             }
  117.             if (botVerL(rem)) {
  118.                 int col = cnt * (s + 2) + cnt;
  119.                 int shuru = 2 + s;
  120.                 int end = shuru + s;
  121.                 for (int i = shuru; i < end; i++) {
  122.                     arr[i][col] = '|';
  123.                 }
  124.             }
  125.             if (botVerR(rem)) {
  126.                 int col = cnt * (s + 2) + cnt + s + 1;
  127.                 int shuru = 2 + s;
  128.                 int end = shuru + s;
  129.                 for (int i = shuru; i < end; i++) {
  130.                     arr[i][col] = '|';
  131.                 }
  132.             }
  133.             if (botHr(rem)) {
  134.                 int row = 2 * s + 2;
  135.                 int shuru = cnt * (s + 2) + (cnt + 1);
  136.                 int end = shuru + s;
  137.                 for (int i = shuru; i < end; i++) {
  138.                     arr[row][i] = '-';
  139.                 }
  140.             }
  141.             cnt++;
  142.             zz++;
  143.         }
  144.         for (int i = 0; i < (2 * s + 3); i++) {
  145.             for (int j = 0; j < (cnt * (s + 2) + cnt) - 1; j++) {
  146.                 cout << arr[i][j];
  147.             }
  148.             cout << endl;
  149.         }
  150.         xyz++;
  151.     }
  152. }
  153. int main()
  154. {
  155.     c_p_c();
  156.     //FastIO;
  157.     //freopen("tttt.in", "r", stdin);
  158.     //freopen("tttt.out", "w", stdout);
  159.     int t = 1;
  160.     //cin >> t;
  161.     while (t--)
  162.         solve();
  163.     return 0;
  164. }
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement