ccdfq @ 2020-03-28 17:50:52
#include<iostream>
using namespace std;
int main()
{
int m,i=0;
char N[100];
cin>>m;
for(i=0;i<m;i++)
{cin>>N[i];}
i=0;
/*for row 1*/
for(i=0;i<m;i++){
switch(N[i]){
case'0':
case'2':
case'3':
case'5':
case'6':
case'7':
case'8':
case'9':
cout<<"XXX.";
break;
case '1':
cout<<"..X.";
break;
case '4':
cout<<"X.X.";
break;
}
}
cout<<"\b "<<endl;
/*for row 2*/
for(i=0;i<m;i++){
switch(N[i]){
case'0':
case'4':
case'8':
case'9':
cout<<"X.X.";
break;
case '1':
case'2':
case'3':
case'7':
cout<<"..X.";
break;
case '5':case'6':
cout<<"X...";
break;
}
}
cout<<"\b "<<endl;
/*for row 3*/
for(i=0;i<m;i++){
switch(N[i]){
case '0':
cout<<"X.X.";
break;
case'1':
case'7':
cout<<"..X.";
break;
case '2':
case'3':
case'4':
case'5':
case'6':
case'8':
case'9':
cout<<"XXX.";
break;
}
}
cout<<"\b "<<endl;
/*for row 4*/
for(i=0;i<m;i++)
{switch(N[i]){
case'0':
case'6':
case'8':
cout<<"X.X.";
break;
case '1':
case'3':
case'4':
case'5':
case'7':
case'9':
cout<<"..X.";
break;
case '2':
cout<<"X...";
break;
}
}
cout<<"\b "<<endl;
/*for row 5*/
for(i=0;i<m;i++){
switch(N[i]){
case '0':
case'2':
case'3':
case'5':
case'6':
case'8':
case'9':
cout<<"XXX.";
break;
case '1':case'4':case'7':
cout<<"..X.";
break;
}
}
cout<<"\b ";
return 0;
}
by liqingyang @ 2020-03-28 17:51:53
@ccdfq 建议打表
by tangrunxi @ 2020-03-28 17:52:38
代码可读性有点差
by liqingyang @ 2020-03-28 17:53:09
@tangrunxi 赞同!
by Kniqht @ 2020-03-28 17:56:21
@liqingyang 打表。。
by liqingyang @ 2020-03-28 17:57:08
@Ax_Plus 怎么了,打表是正解呀,而且打表出省一
by xhQYm @ 2020-03-28 17:57:22
@liqingyang orz
by OutsideR_ @ 2020-03-31 17:52:52
打表不香吗