uva 706 LC-Display

来源:互联网 发布:淘宝拍卖的汽车 编辑:程序博客网 时间:2024/04/25 20:24
/*  LC-Display  蛋疼的模拟题 注意输出的特殊行,如第1行、第2到s+2行、  第s+3到2*s+2行、第2*s+3行,总共有2*s+3行,每一行输出的大小就可以根据s的大小控制了。  数字最大位数为8位*/#include <iostream>#include <cstring>#include<cstdio>using namespace std;#define MAXLENGTH 8void lcd_display (long size, long number){int digits[MAXLENGTH];memset (digits, -1, sizeof (digits));if (number == 0)digits[MAXLENGTH - 1] = 0;else{for (int i = MAXLENGTH - 1; number > 0; i--){digits[i] = number % 10;number /= 10;}}string outline[5][10] = {" - ", "   ", " - ", " - ", "   ", " - ", " - ", " - ", " - ", " - ","| |", "  |", "  |", "  |", "| |", "|  ", "|  ", "  |", "| |", "| |","   ", "   ", " - ", " - ", " - ", " - ", " - ", "   ", " - ", " - ","| |", "  |", "|  ", "  |", "  |", "  |", "| |", "  |", "| |", "  |"," - ", "   ", " - ", " - ", "   ", " - ", " - ", "   ", " - ", " - "};for (int row = 1; row <= (2 * size + 3); row++){for (int i = 0; i < MAXLENGTH; i++)if (digits[i] != -1){string line;if (row == 1)line = outline[0][digits[i]];if (2 <= row && row < (size + 2))line = outline[1][digits[i]];if (row == (size + 2))line = outline[2][digits[i]];if ((size + 3) <= row && row <= (2 * size + 2))line = outline[3][digits[i]];if (row == (2 * size + 3))line = outline[4][digits[i]];cout << line[0];for (int j = 0; j < size; j++) cout << line[1]; cout << line[2];if (i < (MAXLENGTH - 1))cout << " ";}cout<<endl;}}int main (){  //  freopen("./pcio/110104.inp","r",stdin);long size, number;while ((cin >> size >> number, size || number)){lcd_display (size, number);cout << endl;}return 0;}