PC 110104 LC-Display 液晶显示屏//字符串 水题

A friend of yours has just bought a new computer. Before this, the most powerful machine he ever used was a pocket calculator. He is a little disappointed because he liked the LCD display of his calculator more than the screen on his new computer! To make him happy, write a program that prints numbers in LCD display style.

Input

The input file contains several lines, one for each number to be displayed. Each line contains integers s and n, where n is the number to be displayed ( 0<=n<=99, 999, 999) and s is the size in which it shall be displayed ( 1<=s<=10). The input will be terminated by a line containing two zeros, which should not be processed.

Output

Print the numbers specified in the input file in an LCD display-style using s ``-'' signs for the horizontal segments and s ``|'' signs for the vertical ones. Each digit occupies exactly s + 2 columns and 2s + 3 rows. Be sure to fill all the white space occupied by the digits with blanks, including the last digit. There must be exactly one column of blanks between two digits.

Output a blank line after each number. You will find an example of each digit in the sample output below.

Sample Input

2 12345
3 67890
0 0

Sample Output

      --   --        -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        -- 

 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---       
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---

没啥可说的,一次AC
需要注意output的格式,没一个数字后面有一个空列,两个案例之间要有空行

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

char p1[]="- -- -----";
char p2[]="| |  |  |  || ||  |    || || |";
char p3[]="  ----- --";
char p4[]="| |  ||    |  |  || |  || |  |";
char p5[]="- -- -- --";


int main()
{
	int h, w, i, j, k, s, size, middle;
	char num[10];
	while (cin>>s>>num)
	{
		if (s == 0 ) break;
		size =strlen(num);
		for (i=1; i<=s*2+3 ; i++)
		{
			if (i==1)//part 1
			{
				for (j=0; j<size; j++)
				{
					printf(" ");
					for (k=0; k<s; k++)
					{
						cout<<p1[num[j]-48];
					}
					printf(" ");
					if (j<size-1) printf(" ");
				}
			}
			else if (1<i && i<1+s+1)//part 2 
			{
				for (j=0; j<size; j++)
				{
					middle = (num[j]-48) * 3 + 1;
					cout<<p2[middle-1];
					for (k=0;k<s; k++)
					{
						cout<<p2[middle];
					} 
					cout<<p2[middle+1];
					if (j<size-1) printf(" ");
				}
			}
			else if (i == 1+s+1)//part 3
			{
				for (j=0; j<size; j++)
				{
					printf(" ");
					for (k=0; k<s; k++)
					{
						cout<<p3[num[j]-48];
					}
					printf(" ");
					if (j<size-1) printf(" ");
				}
			}
			else if (2+s < i && i<=2+ 2* s)
			{
				for (j=0; j<size; j++)
				{
					middle = (num[j]-48) * 3 + 1;
					cout<<p4[middle-1];
					for (k=0;k<s; k++)
					{
						cout<<p4[middle];
					} 
					cout<<p4[middle+1];
					if (j<size-1) printf(" ");
				}
			}
			else if (i==3+2*s)
			{
				for (j=0; j<size; j++)
				{
					printf(" ");
					for (k=0; k<s; k++)
					{
						cout<<p5[num[j]-48];
					}
					printf(" ");
					if (j<size-1) printf(" ");
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值