张运涛

c++

   :: 首页 :: 联系 :: 聚合  :: 管理

常用链接

留言簿(4)

搜索

  •  

最新评论

#include <iostream>
#include 
<vector>
#include 
<string>
#include 
<algorithm>
using namespace std;

void test1()
{              //1 2 3 4 5 6 7
 int num[][7]= {1,1,1,0,1,1,1
               ,
0,0,1,0,0,1,0
               ,
1,0,1,1,1,0,1
               ,
1,0,1,1,0,1,1
               ,
0,1,1,1,0,1,0
               ,
1,1,0,1,0,1,1
               ,
1,1,0,1,1,1,1
               ,
1,0,1,0,0,1,0
               ,
1,1,1,1,1,1,1
               ,
1,1,1,1,0,1,1 }
;
    
int len; string str;
    
while (cin>>len>>str && len!=0 && str!="0")
    
{    //构建表
        vector<vector<char> > table(2*len+3,vector<char>((len+2)*str.length()+str.length(),' '));
        
int i,j;
        
for (i=0;i<str.length();i++)
        
{   //按行输出
            int th=-3,tv=-2;
            
for (j=0;j<(2*len+3);j++)
            
{
                
if(j%(len+1)==0)
                
{
                    th
+=3;
                    
if(num[str[i]-'0'][th])
                    
{
                        
for(int z=0;z<len;z++)
                            table[j][i
*(len+3)+2+z]='-';
                    }

                }

                
else
                
{
                    
if (j<len+1)
                    
{
                        
if(num[str[i]-'0'][1]) table[j][i*(len+3)+1]='!';
                        
if(num[str[i]-'0'][2]) table[j][i*(len+3)+(len+2)]='!';
                    }
 
                    
else
                    
{
                        
if(num[str[i]-'0'][4]) table[j][i*(len+3)+1]='!';
                        
if(num[str[i]-'0'][5]) table[j][i*(len+3)+(len+2)]='!';
                    }

                }

            }

        }


        
//输出
        for (i=0;i<table.size();i++)
        
{
            copy(table[i].begin()
+1,table[i].end(),ostream_iterator<char>(cout,""));
            cout
<<endl;
        }

    }


}


void main()
{
    test1();
}
//输入每段的长度 及要显示的数字
posted on 2010-05-02 17:55 张运涛 阅读(162) 评论(0)  编辑 收藏 引用 所属分类: 编程练习

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理