light_wind @ 2023-08-08 10:45:06
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int i,j,a[n],x,y=0,t;
const char* m[5][n];
for(i=0;i<n;i++) a[i]=0;
cin>>x;
for(i=0;i<n;i++)
{
t=1;
for(j=1;j<=n-i-1;j++) t*=10;
if(x<t) y++;
else break;
}
for(i=1;i<=n-y;i++)
{
t=1;
for(j=1;j<=n-i-y;j++) t*=10;
a[i+y-1]=x/t%10;
}
for(i=0;i<n;i++)
{
if(a[i]==0)
{
m[0][i]="XXX";
m[1][i]="X.X";
m[2][i]="X.X";
m[3][i]="X.X";
m[4][i]="XXX";
}
else if(a[i]==1)
{
m[0][i]="..X";
m[1][i]="..X";
m[2][i]="..X";
m[3][i]="..X";
m[4][i]="..X";
}
else if(a[i]==2)
{
m[0][i]="XXX";
m[1][i]="..X";
m[2][i]="XXX";
m[3][i]="X..";
m[4][i]="XXX";
}
else if(a[i]==3)
{
m[0][i]="XXX";
m[1][i]="..X";
m[2][i]="XXX";
m[3][i]="..X";
m[4][i]="XXX";
}
else if(a[i]==4)
{
m[0][i]="X.X";
m[1][i]="X.X";
m[2][i]="XXX";
m[3][i]="..X";
m[4][i]="..X";
}
else if(a[i]==5)
{
m[0][i]="XXX";
m[1][i]="X..";
m[2][i]="XXX";
m[3][i]="..X";
m[4][i]="XXX";
}
else if(a[i]==6)
{
m[0][i]="XXX";
m[1][i]="X..";
m[2][i]="XXX";
m[3][i]="X.X";
m[4][i]="XXX";
}
else if(a[i]==7)
{
m[0][i]="XXX";
m[1][i]="..X";
m[2][i]="..X";
m[3][i]="..X";
m[4][i]="..X";
}
else if(a[i]==8)
{
m[0][i]="XXX";
m[1][i]="X.X";
m[2][i]="XXX";
m[3][i]="X.X";
m[4][i]="XXX";
}
else
{
m[0][i]="XXX";
m[1][i]="X.X";
m[2][i]="XXX";
m[3][i]="..X";
m[4][i]="XXX";
}
}
for(i=0;i<5;i++)
{
for(j=0;j<n-1;j++) cout<<m[i][j]<<'.';
cout<<m[i][n-1];
cout<<endl;
}
return 0;
}
by 大海中的孤帆 @ 2023-08-09 09:26:18
@Franklin_editor
数据保证,1,≤n≤100。
by 大海中的孤帆 @ 2023-08-09 09:26:52
@Franklin_editor
您确定int类型的x能存下吗
by 大海中的孤帆 @ 2023-08-09 09:27:56
@Franklin_editor
用string或者char[110]会相对好一点,我拿string过的
#include<iostream>
using namespace std;
string s,s1,s2,s3,s4,s5;
string f0[5]={{'X','X','X'},{'X','.','X'},{'X','.','X'},{'X','.','X'},{'X','X','X'}};
string f1[5]={{'.','.','X'},{'.','.','X'},{'.','.','X'},{'.','.','X'},{'.','.','X'}};
string f2[5]={{'X','X','X'},{'.','.','X'},{'X','X','X'},{'X','.','.'},{'X','X','X'}};
string f3[5]={{'X','X','X'},{'.','.','X'},{'X','X','X'},{'.','.','X'},{'X','X','X'}};
string f4[5]={{'X','.','X'},{'X','.','X'},{'X','X','X'},{'.','.','X'},{'.','.','X'}};
string f5[5]={{'X','X','X'},{'X','.','.'},{'X','X','X'},{'.','.','X'},{'X','X','X'}};
string f6[5]={{'X','X','X'},{'X','.','.'},{'X','X','X'},{'X','.','X'},{'X','X','X'}};
string f7[5]={{'X','X','X'},{'.','.','X'},{'.','.','X'},{'.','.','X'},{'.','.','X'}};
string f8[5]={{'X','X','X'},{'X','.','X'},{'X','X','X'},{'X','.','X'},{'X','X','X'}};
string f9[5]={{'X','X','X'},{'X','.','X'},{'X','X','X'},{'.','.','X'},{'X','X','X'}};
int n;
int main()
{
cin>>n>>s;
for(int i=0;i<n;++i)
{
if(s[i]=='0')
{
s1+=f0[0];
s2+=f0[1];
s3+=f0[2];
s4+=f0[3];
s5+=f0[4];
}
else if(s[i]=='1')
{
s1+=f1[0];
s2+=f1[1];
s3+=f1[2];
s4+=f1[3];
s5+=f1[4];
}
else if(s[i]=='2')
{
s1+=f2[0];
s2+=f2[1];
s3+=f2[2];
s4+=f2[3];
s5+=f2[4];
}
else if(s[i]=='3')
{
s1+=f3[0];
s2+=f3[1];
s3+=f3[2];
s4+=f3[3];
s5+=f3[4];
}
else if(s[i]=='4')
{
s1+=f4[0];
s2+=f4[1];
s3+=f4[2];
s4+=f4[3];
s5+=f4[4];
}
else if(s[i]=='5')
{
s1+=f5[0];
s2+=f5[1];
s3+=f5[2];
s4+=f5[3];
s5+=f5[4];
}
else if(s[i]=='6')
{
s1+=f6[0];
s2+=f6[1];
s3+=f6[2];
s4+=f6[3];
s5+=f6[4];
}
else if(s[i]=='7')
{
s1+=f7[0];
s2+=f7[1];
s3+=f7[2];
s4+=f7[3];
s5+=f7[4];
}
else if(s[i]=='8')
{
s1+=f8[0];
s2+=f8[1];
s3+=f8[2];
s4+=f8[3];
s5+=f8[4];
}
else
{
s1+=f9[0];
s2+=f9[1];
s3+=f9[2];
s4+=f9[3];
s5+=f9[4];
}
if(i<n-1)
{
s1+='.';
s2+='.';
s3+='.';
s4+='.';
s5+='.';
}
}
cout<<s1<<endl<<s2<<endl<<s3<<endl<<s4<<endl<<s5;
return 0;
}