• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            付翔的專(zhuān)欄
            在鄙視中成長(zhǎng) 記錄成長(zhǎng)的點(diǎn)滴
            posts - 106,  comments - 32,  trackbacks - 0

            LC-Display



            A friend of yours has just bought a new computer. Before this, the most powerful machine he ever used was a pocket calculator. He is a little disappointed because he liked the LCD display of his calculator more than the screen on his new computer! To make him happy, write a program that prints numbers in LCD display style.

            Input

            The input file contains several lines, one for each number to be displayed. Each line contains integers s and n, where n is the number to be displayed ( 0$ \le$n$ \le$99, 999, 999) and s is the size in which it shall be displayed ( 1$ \le$s$ \le$10). The input will be terminated by a line containing two zeros, which should not be processed.

            Output

            Print the numbers specified in the input file in an LCD display-style using s ``-'' signs for the horizontal segments and s ``|'' signs for the vertical ones. Each digit occupies exactly s + 2 columns and 2s + 3 rows. Be sure to fill all the white space occupied by the digits with blanks, including the last digit. There must be exactly one column of blanks between two digits.

            Output a blank line after each number. You will find an example of each digit in the sample output below.

            Sample Input

            2 12345
            3 67890
            0 0

            Sample Output

                  --   --        -- 
            | | | | | |
            | | | | | |
            -- -- -- --
            | | | | |
            | | | | |
            -- -- --

            --- --- --- --- ---
            | | | | | | | |
            | | | | | | | |
            | | | | | | | |
            --- --- ---
            | | | | | | | |
            | | | | | | | |
            | | | | | | | |
            --- --- --- ---




            #include <iostream>
            using namespace std;

             
            int display[10][7];
            void init ()
            {
                display[
            0][0]=display[0][1]=display[0][2]=display[0][4]=display[0][5]=display[0][6]=1;
                display[
            1][2]=display[1][5= 1;
                display[
            2][0]=display[2][2]=display[2][3]=display[2][4]=display[2][6]=1;
                display[
            3][0]=display[3][2]=display[3][3]=display[3][5]=display[3][6]=1;
                display[
            4][1]=display[4][2]=display[4][3]=display[4][5]=1;
                display[
            5][0]=display[5][1]=display[5][3]=display[5][5]=display[5][6]=1;
                display[
            6][0]=display[6][1]=display[6][3]=display[6][4]=display[6][5]=display[6][6]=1;
                display[
            7][0]=display[7][2]=display[7][5]=1;
                display[
            8][0]=display[8][1]=display[8][2]=display[8][3]=display[8][4]=display[8][5]=display[8][6]=1;
                display[
            9][0]=display[9][1]=display[9][2]=display[9][3]=display[9][5]=display[9][6]=1;
                
            }
            int fun(int row)
            {
                
            if(row == 1)
                    
            return 0;
                
            if(row == 2)
                    
            return 1;
                
            if(row ==3)
                    
            return 3;
                
            if(row == 4)
                    
            return 4;
                
            if(row == 5)
                    
            return 6;
                
            }
            void work(int s,int row,int n)
            {
                
            char temp[10],c;
                
            int len,i,j,ans,k;
                itoa(n,temp,
            10);
                len 
            = strlen(temp);
                
            if(row %2 ==1)
                {
                    ans 
            = fun(row);
                    
            //printf(" ");
                    for(i = 0; i < len ; i ++)
                    {
                        printf(
            " ");
                        
            //if(temp[i]-'0' != 1)
                        
            //{
                            for(j = 0 ; j < s; j ++)
                            {
                                
            if(display[temp[i]-'0'][ans]==1)
                                    printf(
            "-");
                                
            else printf(" ");
                            }    
                        
            //}
                        printf(" %c",(i == len-1)?'\n':' ');
                        
                        
                    }
                    
                }
                
                
            else if(row %2== 0)
                {
                    ans 
            = fun(row);
                    
            for(i = 0; i < s ; i ++)
                    {
                        
            for(j = 0 ; j < len; j ++)
                        {
                            
            if(display[temp[j]-'0'][ans]==1)
                                printf(
            "|");
                            
            else printf(" ");
                            
                            
            //if(temp[j]-'0' != 1)
                            
            //{
                                for(k = 0; k < s ; k ++)
                                    printf(
            " ");
                                
            //    for(j = 0 ; j < len; j ++)
                                
            //    {
                                if(display[temp[j]-'0'][ans+1]==1)
                                    printf(
            "|");
                                
            else printf(" ");
                            
            //}
                            if(j != len-1) printf(" ");
                        }
                        
            //    }
                        printf("\n");                
                        
                    }
                    
                }
            }
            void solve(int s,int n)
            {
                
            for(int i = 1; i <= 5; i ++)work(s,i,n);
            }

            int main()
            {
                
            //freopen("in.txt","r",stdin);
                int s,n;
                init();
                
            while(scanf("%d%d",&s,&n),s||n)
                {
                    solve(s,n);
                }
                
            return 0;
            }

            posted on 2010-07-22 18:13 付翔 閱讀(184) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): ACM 數(shù)據(jù)結(jié)構(gòu)

            <2010年7月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(2)

            隨筆分類(lèi)

            隨筆檔案

            文章分類(lèi)

            文章檔案

            CSDN - 我的blog地址

            博客

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            国产亚洲精品美女久久久| 久久电影网一区| 久久久久亚洲AV无码专区桃色| 久久影院综合精品| 精产国品久久一二三产区区别| 精品久久久久中文字幕一区| 国产精品久久国产精麻豆99网站| 色综合久久久久无码专区| 国内精品久久久久久久久电影网| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 狠色狠色狠狠色综合久久| 东京热TOKYO综合久久精品| 久久婷婷五月综合色高清| 久久精品水蜜桃av综合天堂 | 亚洲∧v久久久无码精品| 99精品国产99久久久久久97| 99久久国产宗和精品1上映| 中文字幕精品无码久久久久久3D日动漫 | 亚洲国产天堂久久综合网站| 亚洲国产精品婷婷久久| 久久精品国产第一区二区| 久久久久这里只有精品| 久久亚洲精品国产精品婷婷| 少妇熟女久久综合网色欲| 中文字幕乱码人妻无码久久| 久久亚洲精品无码AV红樱桃| 国产精品久久毛片完整版| 99久久精品国产一区二区| 久久久久噜噜噜亚洲熟女综合| 久久久无码精品午夜| 久久精品国产男包| 久久精品无码一区二区无码| 93精91精品国产综合久久香蕉| 国产精品美女久久久免费| 热久久国产欧美一区二区精品| 少妇无套内谢久久久久| 97久久久久人妻精品专区| 久久九九久精品国产免费直播| 奇米影视7777久久精品人人爽| 欧美黑人又粗又大久久久| 99久久国产综合精品五月天喷水|