poj 1102 LC—display

题意:像这样的显示数字

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;
//}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值