Kaedehara_Kazuha1029 @ 2021-04-18 10:56:15
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int d[1005][6];//d[横坐标][纵坐标]
int num[105];
int main(){
int n, number;
cin >> n;
cin >> number;
for(int i = n; i >= 1; i--){
num[i] = number%10;
number /= 10;
//cout << number%10 << " ";
}
//for(int i = 1; i <= n; i++) cout << num[i];
for(int i = 0; i < n; i++){//对二维数组进行赋值 -> 1 = "X" ; 2 = "."
if(num[i+1] == 0) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=1, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=2, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=1, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 1) d[i*4+1][1]=2, d[i*4+2][1]=2, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=2, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=2, d[i*4+2][3]=2, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=2, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=2, d[i*4+2][5]=2, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 2) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=2, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=1, d[i*4+2][4]=2, d[i*4+3][4]=2, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 3) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=2, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=2, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 4) d[i*4+1][1]=1, d[i*4+2][1]=2, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=1, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=2, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=2, d[i*4+2][5]=2, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 5) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=1, d[i*4+2][2]=2, d[i*4+3][2]=2, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=2, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 6) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=1, d[i*4+2][2]=2, d[i*4+3][2]=2, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=1, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 7) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=2, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=2, d[i*4+2][3]=2, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=2, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=2, d[i*4+2][5]=2, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 8) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=1, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=1, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(num[i+1] == 9) d[i*4+1][1]=1, d[i*4+2][1]=1, d[i*4+3][1]=1, d[i*4+4][1]=2, d[i*4+1][2]=1, d[i*4+2][2]=2, d[i*4+3][2]=1, d[i*4+4][2]=2, d[i*4+1][3]=1, d[i*4+2][3]=1, d[i*4+3][3]=1, d[i*4+4][3]=2, d[i*4+1][4]=2, d[i*4+2][4]=2, d[i*4+3][4]=1, d[i*4+4][4]=2, d[i*4+1][5]=1, d[i*4+2][5]=1, d[i*4+3][5]=1, d[i*4+4][5]=2;
if(i == n-1) d[i*4+4][1]=0, d[i*4+4][2]=0, d[i*4+4][3]=0, d[i*4+4][4]=0, d[i*4+4][5]=0;
}
for(int i = 1; i <= 6; i++){ //数组遍历,转化为图形
for(int j = 1; j <= 1000; j++){
if(d[j][i] == 1) cout << "X";
if(d[j][i] == 2) cout << ".";
}
cout << endl;
}
}
by Kaedehara_Kazuha1029 @ 2021-04-18 10:57:00
代码有些复杂(弱)
by osfly @ 2021-04-18 11:06:06
你这样没人帮你看的(起码缩进一下嘛
建议整理一下重新复制
by zhouyuhang @ 2021-04-18 11:22:42
数据范围是<=100位,int肯定炸了。
换成string类型,记得加头文件<cstring>
//读入
int n;
string s;
cin>>n>>s;
for(int i=0;i<n;i++) num[i+1]=s[i]-'0';
by zhouyuhang @ 2021-04-18 11:26:01
@201980319穆浩宇