Diamiko @ 2020-03-10 18:46:13
n=int(input())
s=input()
for j in range(1,6):
cnt=1
for i in s:
if j==1:
if i=='0':
print('XXX',end='')
elif i=='1':
print('..X',end='')
elif i=='2':
print('XXX',end='')
elif i=='3':
print('XXX',end='')
elif i=='4':
print('X.X',end='')
elif i=='5':
print('XXX',end='')
elif i=='6':
print('XXX',end='')
elif i=='7':
print('XXX',end='')
elif i=='8':
print('XXX',end='')
elif i=='9':
print('XXX',end='')
if j==2:
if i=='0':
print('X.X',end='')
elif i=='1':
print('..X',end='')
elif i=='2':
print('..X',end='')
elif i=='3':
print('..X',end='')
elif i=='4':
print('X.X',end='')
elif i=='5':
print('X..',end='')
elif i=='6':
print('X..',end='')
elif i=='7':
print('..X',end='')
elif i=='8':
print('X.X',end='')
elif i=='9':
print('X.X',end='')
if j==3:
if i=='0':
print('X.X',end='')
elif i=='1':
print('..X',end='')
elif i=='2':
print('XXX',end='')
elif i=='3':
print('XXX',end='')
elif i=='4':
print('XXX',end='')
elif i=='5':
print('XXX',end='')
elif i=='6':
print('XXX',end='')
elif i=='7':
print('..X',end='')
elif i=='8':
print('XXX',end='')
elif i=='9':
print('XXX',end='')
if j==4:
if i=='0':
print('X.X',end='')
elif i=='1':
print('..X',end='')
elif i=='2':
print('X..',end='')
elif i=='3':
print('..X',end='')
elif i=='4':
print('..X',end='')
elif i=='5':
print('..X',end='')
elif i=='6':
print('X.X',end='')
elif i=='7':
print('..X',end='')
elif i=='8':
print('X.X',end='')
elif i=='9':
print('..X',end='')
if j==5:
if i=='0':
print('XXX',end='')
elif i=='1':
print('..X',end='')
elif i=='2':
print('XXX',end='')
elif i=='3':
print('XXX',end='')
elif i=='4':
print('..X',end='')
elif i=='5':
print('XXX',end='')
elif i=='6':
print('XXX',end='')
elif i=='7':
print('..X',end='')
elif i=='8':
print('XXX',end='')
elif i=='9':
print('XXX',end='')
if cnt!=n:
print('.',end='')
cnt+=1
print('')
帮帮孩子吧
by NXYorz @ 2020-03-10 18:58:46
和样例输出一样...
emmmm
by liqingyang @ 2020-03-10 18:59:08
您就不能简洁些吗?
打表不行吗?
by liqingyang @ 2020-03-10 18:59:57
就像我一样(其实也不是太简洁):
#include<iostream>
#include<string>
using namespace std;
bool ans[10][5][5]=
{
{{1,1,1},{1,0,1},{1,0,1},{1,0,1},{1,1,1}},
{{0,0,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}},
{{1,1,1},{0,0,1},{1,1,1},{1,0,0},{1,1,1}},
{{1,1,1},{0,0,1},{1,1,1},{0,0,1},{1,1,1}},
{{1,0,1},{1,0,1},{1,1,1},{0,0,1},{0,0,1}},
{{1,1,1},{1,0,0},{1,1,1},{0,0,1},{1,1,1}},
{{1,1,1},{1,0,0},{1,1,1},{1,0,1},{1,1,1}},
{{1,1,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}},
{{1,1,1},{1,0,1},{1,1,1},{1,0,1},{1,1,1}},
{{1,1,1},{1,0,1},{1,1,1},{0,0,1},{1,1,1}}
};
int n,a[110];
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
char ch;
cin>>ch;
a[i]=ch-'0';
}
for(int i=0;i<5;i++)
{
for(int j=0;j<n;j++)
{
for(int k=0;k<3;k++)
{
cout<<(ans[a[j]][i][k]?"X":".");
}
if(j!=n-1)
{
cout<<".";
}
}
cout<<endl;
}
return 0;
}
by liqingyang @ 2020-03-10 19:00:53
@弑魂丶琉璃花P python应该比C++好些呀!
by NXYorz @ 2020-03-10 19:01:16
#include<iostream>
#include<cstdio>
#define N 101
using namespace std;
int n;
char a[N];
char a_0[6][4]={ 0,0,0,0,
'0','X','X','X',
'0','X','.','X',
'0','X','.','X',
'0','X','.','X',
'0','X','X','X'};
char b_1[6][4]={0,0,0,0,
'0','.','.','X',
'0','.','.','X',
'0','.','.','X',
'0','.','.','X',
'0','.','.','X'};
char c_2[6][4]={0,0,0,0,
'0','X','X','X',
'0','.','.','X',
'0','X','X','X',
'0','X','.','.',
'0','X','X','X'};
char d_3[6][4]={0,0,0,0,
'0','X','X','X',
'0','.','.','X',
'0','X','X','X',
'0','.','.','X',
'0','X','X','X'};
char e_4[6][4]={0,0,0,0,
'0','X','.','X',
'0','X','.','X',
'0','X','X','X',
'0','.','.','X',
'0','.','.','X'};
char f_5[6][4]={0,0,0,0,
'0','X','X','X',
'0','X','.','.',
'0','X','X','X',
'0','.','.','X',
'0','X','X','X'};
char g_6[6][4]={0,0,0,0,
'0','X','X','X',
'0','X','.','.',
'0','X','X','X',
'0','X','.','X',
'0','X','X','X'};
char h_7[6][4]={0,0,0,0,
'0','X','X','X',
'0','.','.','X',
'0','.','.','X',
'0','.','.','X',
'0','.','.','X'};
char i_8[6][4]={0,0,0,0,
'0','X','X','X',
'0','X','.','X',
'0','X','X','X',
'0','X','.','X',
'0','X','X','X'};
char j_9[6][4]={0,0,0,0,
'0','X','X','X',
'0','X','.','X',
'0','X','X','X',
'0','.','.','X',
'0','X','X','X'};
int main()
{
scanf("%d",&n);
cin>>a;
int tot=1;
while(tot<=5)
{
for(int i=0;i<n;i++)
{
if(a[i]-'0'==0)
for(int j=1;j<=3;j++)
printf("%c",a_0[tot][j]);
if(a[i]-'0'==1)
for(int j=1;j<=3;j++)
printf("%c",b_1[tot][j]);
if(a[i]-'0'==2)
for(int j=1;j<=3;j++)
printf("%c",c_2[tot][j]);
if(a[i]-'0'==3)
for(int j=1;j<=3;j++)
printf("%c",d_3[tot][j]);
if(a[i]-'0'==4)
for(int j=1;j<=3;j++)
printf("%c",e_4[tot][j]);
if(a[i]-'0'==5)
for(int j=1;j<=3;j++)
printf("%c",f_5[tot][j]);
if(a[i]-'0'==6)
for(int j=1;j<=3;j++)
printf("%c",g_6[tot][j]);
if(a[i]-'0'==7)
for(int j=1;j<=3;j++)
printf("%c",h_7[tot][j]);
if(a[i]-'0'==8)
for(int j=1;j<=3;j++)
printf("%c",i_8[tot][j]);
if(a[i]-'0'==9)
for(int j=1;j<=3;j++)
printf("%c",j_9[tot][j]);
if(i!=n-1) printf(".");
}
printf("\n");tot++;
}
}
by mot1ve @ 2020-03-10 19:01:32
我不会python啊,话说noip也不能有python吧
by NXYorz @ 2020-03-10 19:01:44
打表..本蒟蒻只会打表
by Ryo_Yamada @ 2020-03-10 19:04:20
@弑魂丶琉璃花P 您cnt=1
应该设在j
循环外面,否则每行末尾都会输出一个多余的.
同时建议打个表,不要这样判断,容易出错
by NXYorz @ 2020-03-10 19:05:08
@弑魂丶琉璃花P
您的最后一行有没有输出
by Ryo_Yamada @ 2020-03-10 19:06:16
@弑魂丶琉璃花P “和样例输出一样”您确定?