uva 706 LC-Display

简介: /* 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
/*
  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 8
void 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;
}

目录
相关文章
UVa 374 Big Mod
UVa 374 Big Mod
38 0
UVa343 What Base Is This
UVa343 What Base Is This
43 0
UVa11076 - Add Again
UVa11076 - Add Again
51 0
POJ 2840 Big Clock
POJ 2840 Big Clock
106 0
|
机器学习/深度学习 人工智能 BI
POJ 2840 Big Clock
Description Our vicar raised money to have the church clock repaired for several weeks. The big clock, which used to strike the hours days...
915 0