这一天qls在学校综合楼等电梯的时候看到了电梯数字的样子,突然觉得这样写数字特别有趣,于是自己想用程序跑出来。由于正常大小输出数字太小了,qls决定加大难度,他想画出不同大小的数字,你能帮他解决这个问题吗?
输入格式:
第一行输入一个数字n表示数字的大小(具体大小解释见样例解释)。(3≤n≤10)
第二行输入一串只含数字的字符串。(字符串长度不超过20)
输出格式:
输出字符串的图像,每两个数字图像之间有一个空格(具体解释见样例解释)。
样例1
样例输入
3
123
样例输出
* *** ***
* * *
* *** ***
* * *
* *** ***
样例2
样例输入
4
567
样例输出
**** **** ****
* * *
* * *
**** **** *
* * * *
* * * *
**** **** *
提示
数字按照电梯样式并用字符‘*’表示边,大小的定义是在一个n×(2n−1)的长方形表示数字,每两个数字之间用空格间隔。
例如大小为3的0到9样式如下:
代码长度限制
16 KB
时间限制
1000 ms
内存限制
256 MB
栈限制
8192 KB
纯模拟,没有别的,注意细节就行
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define PII pair<int,int>
#define fi first
#define pb push_back
#define sec second
#define endl '\n'
#define INF 0x3f3f3f3f
const int N=2e5+10;
const int M=1e6+10;
int n,m,k,T;
void draw(int x,int y ){
int a ;
if(y==1){
if(x==1){
a=n-1;
while(a--){
cout << " ";
}
cout << "*";
}else if(x==2||x==3||x==0||x==5||x==6||x==7||x==8||x==9){
a=n;
while(a--){
cout << '*';
}
}else{
cout << '*';
a=n-2;
while(a--)cout << ' ';
cout << "*";
}
}else if(y==m){
if(x==0||x==2||x==3||x==5||x==6||x==8||x==9){
a=n;
while(a--){
cout << '*';
}
}else if(x==1||x==4||x==7){
a=n-1;
while(a--)cout << ' ';
cout << "*";
}else{
}
}else if(y==m/2+1){
if(x==2||x==3||x==4||x==5||x==6||x==8||x==9){
a=n;
while(a--){
cout << '*';
}
}else if(x==0){
cout << '*';
a=n-2;
while(a--)cout << ' ';
cout << "*";
}else if(x==1||x==7){
a=n-1;
while(a--)cout << ' ';
cout << '*';
}
}else if(y<m/2+1){
if(x==0||x==4||x==8||x==9){
a=n-2;
cout << '*';
while(a--)cout << ' ';
cout << '*';
}else if(x==1||x==2||x==3||x==7){
a=n-1;
while(a--)cout << ' ';
cout << '*';
}else{
a=n-1;
cout << '*';
while(a--)cout << ' ';
}
}else{
if(x==0||x==6||x==8){
a=n-2;
cout << '*';
while(a--)cout << ' ';
cout << '*';
}else if(x==1||x==3||x==4||x==5||x==7||x==9){
a=n-1;
while(a--)cout << ' ';
cout << '*';
}else{
cout << '*';
a=n-1;
while(a--)cout << ' ';
}
}
}
signed main(){
cin >> n ;
string s ;
cin >> s ;
m=2*n-1;
for(int j=1;j<=m;j++){
for(int i=0;i<s.size();i++){
if(i!=0)cout << ' ';
draw(s[i]-48,j);
}
cout << endl;
}
return 0;
}