P5730 深基5.例10显示屏

Posted Kunkun只喝怡宝

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了P5730 深基5.例10显示屏相关的知识,希望对你有一定的参考价值。

题目描述

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

代码

用五个二维数组分别存储每个数字每一行的三个字母,最后一行一行的输出就好了。

#include<bits/stdc++.h>

using namespace std;

int main(){
	int n,i;
	char a[100],
	b1[10][4]={"XXX","..X","XXX","XXX","X.X","XXX","XXX","XXX","XXX","XXX"},
	b2[10][4]={"X.X","..X","..X","..X","X.X","X..","X..","..X","X.X","X.X"},
	b3[10][4]={"X.X","..X","XXX","XXX","XXX","XXX","XXX","..X","XXX","XXX"},
	b4[10][4]={"X.X","..X","X..","..X","..X","..X","X.X","..X","X.X","..X"},
	b5[10][4]={"XXX","..X","XXX","XXX","..X","XXX","XXX","..X","XXX","XXX"};
	cin>>n>>a;
	for(i=0;i<n;i++){
		cout<<b1[a[i]-'0'];
		if(i<n-1) cout<<'.';
		else cout<<endl;
	}
	for(i=0;i<n;i++){
		cout<<b2[a[i]-'0'];
		if(i<n-1) cout<<'.';
		else cout<<endl;
	}for(i=0;i<n;i++){
		cout<<b3[a[i]-'0'];
		if(i<n-1) cout<<'.';
		else cout<<endl;
	}for(i=0;i<n;i++){
		cout<<b4[a[i]-'0'];
		if(i<n-1) cout<<'.';
		else cout<<endl;
	}for(i=0;i<n;i++){
		cout<<b5[a[i]-'0'];
		if(i<n-1) cout<<'.';
		else cout<<endl;
	}
	return 0;
}

以上是关于P5730 深基5.例10显示屏的主要内容,如果未能解决你的问题,请参考以下文章

入门4数组

入门4数组

P5729 深基5.例7工艺品制作

P5731 深基5.习6蛇形方阵

P5727 深基5.例3冰雹猜想

P5728 深基5.例5旗鼓相当的对手