~cpp //706 #include <iostream> using namespace std; #include <string> bool display[8][7]; // 최대 8자리, 한 숫자를 나타내는데 필요한 선은 7개 void makeDisplay(string n) // 수를 입력받음 { int i, j; for (i = 0; i < 8; i++) for (j = 0; j < 7; j++) display[i][j] = false; for (i = 0; i < n.length(); i++) { switch (n[i]) { case '1': display[i][2] = display[i][5] = true; break; case '2': display[i][0] = display[i][2] = display[i][3] = display[i][4] = display[i][6] = true; break; case '3': display[i][0] = display[i][2] = display[i][3] = display[i][5] = display[i][6] = true; break; case '4': display[i][1] = display[i][2] = display[i][3] = display[i][5] = true; break; case '5': display[i][0] = display[i][1] = display[i][3] = display[i][5] = display[i][6] = true; break; case '6': display[i][0] = display[i][1] = display[i][3] = display[i][4] = display[i][5] = display[i][6] = true; break; case '7': display[i][0] = display[i][2] = display[i][5] = true; break; case '8': display[i][0] = display[i][1] = display[i][2] = display[i][3] = display[i][4] = display[i][5] = display[i][6] = true; break; case '9': display[i][0] = display[i][1] = display[i][2] = display[i][3] = display[i][5] = display[i][6] = true; break; case '0': display[i][0] = display[i][1] = display[i][2] = display[i][4] = display[i][5] = display[i][6] = true; break; } } } void showDisplay(int s, int length) // 크기와 자리수를 입력받음 { int i, j, k, l; for (k = 0; k < length; k++) { cout << " "; if (display[k][0]) for (l = 0; l < s; l++) cout << "-"; else for (l = 0; l < s; l++) cout << " "; cout << " "; cout << " "; } cout << endl; for (i = 0; i < s; i++) { for (k = 0; k < length; k++) { if (display[k][1]) cout << "|"; else cout << " "; for (l = 0; l < s; l++) cout << " "; if (display[k][2]) cout << "|"; else cout << " "; cout << " "; } cout << endl; } for (k = 0; k < length; k++) { cout << " "; if (display[k][3]) for (l = 0; l < s; l++) cout << "-"; else for (l = 0; l < s; l++) cout << " "; cout << " "; cout << " "; } cout << endl; for (i = 0; i < s; i++) { for (k = 0; k < length; k++) { if (display[k][4]) cout << "|"; else cout << " "; for (l = 0; l < s; l++) cout << " "; if (display[k][5]) cout << "|"; else cout << " "; cout << " "; } cout << endl; } for (k = 0; k < length; k++) { cout << " "; if (display[k][6]) for (l = 0; l < s; l++) cout << "-"; else for (l = 0; l < s; l++) cout << " "; cout << " "; cout << " "; } cout << endl << endl; } int main() { int s; // 사이즈 string n; // 넘버 while (cin >> s >> n) { if (s == 0) break; makeDisplay(n); showDisplay(s, n.length()); } return 0; }