题意:像这样的显示数字
2 12345 3 67890 0 0
Sample Output
-- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- ---
模拟即可:
#include<iostream>
#include<stack>
#include<list>
#include<cmath>
#include<cctype>
#include<vector>
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<fstream>
#include<algorithm>
using namespace std;
#define HORIZONTAL_GRID cout<<'-'
#define VERTICAL_GRID cout<<'|'
#define BLANK_GRID cout<<' '
//char s[3000], m;
//void putzero(const int &s, const int &row, const int &col)
//{
// int i, j;
// for(i=0; i<row; i++)
// {
// for(j=0; j<col; j++)
// {
// if( ( i==0 || i==row-1 ) && ( j!=0 && j!=col-1 ) )
// HORIZONTAL_GRID;
// else if( ( i!=0 && i!=s+1 && i!=row-1 ) && ( j==0 || j==col-1 ) )
// VERTICAL_GRID;
// else BLANK_GRID;
// }
// cout<<endl;
// }
//}
int main(int argc, char *argv[])
{
int s, i, j, k, len, row, col;
char n[12];
while( cin>>s>>n )
{
if( s==0 && strcmp(n, "0")==0 ) break;
len=strlen(n);
col=s+2;
row=2*s+3;
for(i=0; i<len; i++)
{
for(j=0; j<col; j++)
{
if( n[i]!='1' && n[i]!='4' )
if( j!=0 && j!=col-1 ) { HORIZONTAL_GRID; continue; }
BLANK_GRID;
}
if( i!=len-1) BLANK_GRID;
}
cout<<endl;
for(k=0; k<s; k++)
{
for(i=0; i<len; i++)
{
for(j=0; j<col; j++)
{
if( j==0 )
if( n[i]!='1' && n[i]!='2' && n[i]!='3' && n[i]!='7' )
{ VERTICAL_GRID; continue; }
if( j==col-1 )
if( n[i]!='5' && n[i]!='6' )
{ VERTICAL_GRID; continue; }
BLANK_GRID;
}
if( i!=len-1) BLANK_GRID;
}
cout<<endl;
}
for(i=0; i<len; i++)
{
for(j=0; j<col; j++)
{
if( j!=0 && j!=col-1 )
if( n[i]!='1' && n[i]!='7' && n[i]!='0' )
{ HORIZONTAL_GRID; continue; }
BLANK_GRID;
}
if( i!=len-1) BLANK_GRID;
}
cout<<endl;
for(k=0; k<s; k++)
{
for(i=0; i<len; i++)
{
for(j=0; j<col; j++)
{
if( j==0 )
if( n[i]=='2' || n[i]=='6' || n[i]=='8' || n[i]=='0' )
{ VERTICAL_GRID; continue; }
if( j==col-1 )
if( n[i]!='2' )
{ VERTICAL_GRID; continue; }
BLANK_GRID;
}
if( i!=len-1) BLANK_GRID;
}
cout<<endl;
}
for(i=0; i<len; i++)
{
for(j=0; j<col; j++)
{
if( j!=0 && j!=col-1 )
if( n[i]!='1' && n[i]!='4' && n[i]!='7' )
{ HORIZONTAL_GRID; continue; }
BLANK_GRID;
}
if( i!=len-1) BLANK_GRID;
}
cout<<endl<<endl;
}
return 0;
}
// for(i=0; i<row; i++)
// {
// for(j=0; j<len; j++)
// {
// for(k=0; k<col; k++)
// {
// if( s[j]=='0' )
// }
// }
// }
// /*switch( n[i] )
// {
//
// case '0': putzero(s, row, col); break;
// case '1': putone(s, row, col); break;
// case '2': puttwo(s, row, col); break;
// case '3': putthree(s, row, col); break;
// case '4': putfour(s, row, col); break;
// case '5': putfive(s, row, col); break;
// case '6': putsix(s, row, col); break;
// case '7': putseven(s, row, col); break;
// case '8': puteight(s, row, col); break;
// case '9': putnine(s, row, col); break;
// default : break;
// }*/
// //}
// }
// return 0;
//}