荧光屏编程
题目描述
荧光屏编程(具体看样例即可,玩过计算器的都懂)
输入格式
输入四个整数a,b,c,d(0<=a,b,c,d<=9)
输出格式
输出一个5×23的字符串矩阵,‘-’表示不亮,‘*’表示亮,每两个数字显示之间有一列空格(末尾没有)
样例输入
Sample1:
1 2 3 4
Sample2:
5 6 7 8
Sample3:
9 0 1 2
样例输出
Sample1:
----* ***** ***** *---*
----* ----* ----* *---*
----* ***** ***** *****
----* *---- ----* ----*
----* ***** ***** ----*
Sample2:
***** ***** ***** *****
*---- *---- ----* *---*
***** ***** ----* *****
----* *---* ----* *---*
***** ***** ----* *****
Sample3:
***** ***** ----* *****
*---* *---* ----* ----*
***** *---* ----* *****
----* *---* ----* *----
***** ***** ----* *****
思路:
找规律,找出每个数字的组合,然后输出即可。
#include<bits/stdc++.h>
using namespace std;
string s[4]={"*----","----*","*---*","*****"};
int mapp[10][5]={{3,2,2,2,3},{1,1,1,1,1},{3,1,3,0,3},{3,1,3,1,3},
{2,2,3,1,1},{3,0,3,1,3},{3,0,3,2,3},
{3,1,1,1,1},{3,2,3,2,3},{3,2,3,1,3}
};
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
for(int i=0;i<5;i++){
cout<<s[mapp[a][i]]<<" ";
cout<<s[mapp[b][i]]<<" ";
cout<<s[mapp[c][i]]<<" ";
cout<<s[mapp[d][i]]<<endl;
}
}