P5730 【深基5.例10】显示屏

题目描述

液晶屏上,每个阿拉伯数字都是可以显示成 3×5 的点阵的(其中 X 表示亮点,. 表示暗点)。现在给出数字位数(不超过 100)和一串数字,要求输出这些数字在显示屏上的效果。数字的显示方式如同样例输出,注意每个数字之间都有一列间隔。

输入格式

输出格式

输入输出样例

输入 输出
10
0123456789
XXX...X.XXX.XXX.X.X.XXX.XXX.XXX.XXX.XXX
X.X...X...X...X.X.X.X...X.....X.X.X.X.X
X.X...X.XXX.XXX.XXX.XXX.XXX...X.XXX.XXX
X.X...X.X.....X...X...X.X.X...X.X.X...X
XXX...X.XXX.XXX...X.XXX.XXX...X.XXX.XXX

解答

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int a0[5][3]={
	{1,1,1},
	{1,0,1},
	{1,0,1},
	{1,0,1},
	{1,1,1}
	};
	int a1[5][3]={
	{0,0,1},
	{0,0,1},
	{0,0,1},
	{0,0,1},
	{0,0,1}
	};
	int a2[5][3]={
	{1,1,1},
	{0,0,1},
	{1,1,1},
	{1,0,0},
	{1,1,1}
	};
	int a3[5][3]={
	{1,1,1},
	{0,0,1},
	{1,1,1},
	{0,0,1},
	{1,1,1}
	};
	int a4[5][3]={
	{1,0,1},
	{1,0,1},
	{1,1,1},
	{0,0,1},
	{0,0,1}
	};
	int a5[5][3]={
	{1,1,1},
	{1,0,0},
	{1,1,1},
	{0,0,1},
	{1,1,1}
	};
	int a6[5][3]={
	{1,1,1},
	{1,0,0},
	{1,1,1},
	{1,0,1},
	{1,1,1}
	};
	int a7[5][3]={
	{1,1,1},
	{0,0,1},
	{0,0,1},
	{0,0,1},
	{0,0,1}
	};
	int a8[5][3]={
	{1,1,1},
	{1,0,1},
	{1,1,1},
	{1,0,1},
	{1,1,1}
	};
	int a9[5][3]={
	{1,1,1},
	{1,0,1},
	{1,1,1},
	{0,0,1},
	{1,1,1}
	};
	int n;
	cin>>n;
	int a[5][3*n+n];
	memset(a,0,sizeof(a));
	for(int i=0;i<n;i++)
	{
		char num;
		cin>>num;

		for(int k=0;k<5;k++)
		{
			for(int j=0;j<3;j++)
			{
				switch(num)
				{
					case '0':
						a[k][4*i+j]=a0[k][j];
						break;
					case '1':
						a[k][4*i+j]=a1[k][j];
						break;
					case '2':
						a[k][4*i+j]=a2[k][j];
						break;
					case '3':
						a[k][4*i+j]=a3[k][j];
						break;
					case '4':
						a[k][4*i+j]=a4[k][j];
						break;
					case '5':
						a[k][4*i+j]=a5[k][j];
						break;
					case '6':
						a[k][4*i+j]=a6[k][j];
						break;
					case '7':
						a[k][4*i+j]=a7[k][j];
						break;
					case '8':
						a[k][4*i+j]=a8[k][j];
						break;
					case '9':
						a[k][4*i+j]=a9[k][j];
						break;
				}
			}
		}
	}
	
	for(int k=0;k<5;k++)
	{
		for(int i=0;i<3*n+n-1;i++)
		{
			char output=a[k][i]==1?'X':'.';
			cout<<output;
		}
		cout<<endl;
	}

	return 0;
} 
上一篇:python-selenium实现的简易下载器,并常见错误解决


下一篇:iOS-Git(git Failed to connect to 127.0.0.1 port xxxx: Connection refused)