POJ 1102 - LC-Display

Description

A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed, because he liked the LC-display of his calculator so much. So you decide to write a program that displays numbers in an LC-display-like style on his computer.

Input

The input contains several lines, on e for each number to be displayed. Each line contains two integers s, n (1 <= s <= 10, 0 <= n <= 99 999 999), where n is the number to be displayed and s is the size in which it shall be displayed. 

The input file will be terminated by a line containing two zeros. This line should not be processed.

Output

Output the numbers given in the input file in an LC-display-style using s "-" signs for the horizontal segments and s "|" signs for the vertical on es. 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, also for the last digit.) There has to be exactly on e column of blanks between two digits. 

Output a blank line after each number. (You will find a sample of each digit in the sample output.)

Sample Input

2 12345
3 67890
0 0

Sample Output

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

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

Source


看看sample input和sample output就知道它让你干嘛了……所以一行行暴力一点的输出就好
#include<stdio.h>
#include<string.h>
void row_0(int n){int i;for(i=1;i<=n+2;i++) printf(" ");}
void row_1(int n){int i;printf(" ");for(i=1;i<=n;i++) printf("-");printf(" ");}
void col_l(int n){int i;printf("|");for(i=1;i<=n+1;i++) printf(" ");}
void col_r(int n){int i;for(i=1;i<=n+1;i++) printf(" ");printf("|");}
void col_b(int n){int i;printf("|");for(i=1;i<=n;i++) printf(" ");printf("|");}
void display(int num[],int n)
{
int r,c,i;
for(r=1;r<=2*n+3;r++){
//输出三个衡横行
if((r-1)%(n+1)==0)
for(c=0;num[c]>=0;c++){
if(num[c]==2 || num[c]==3 || num[c]==5 || num[c]==6 || num[c]==8 || num[c]==9) row_1(n);
if(num[c]==1) for(i=1;i<=n+2;i++) printf(" ");
if(num[c]==4){
if((r-1)/(n+1)==1) row_1(n);
else row_0(n);
}
if(num[c]==7){
if((r-1)/(n+1)==0) row_1(n);
else row_0(n);
}
if(num[c]==0){
if((r-1)/(n+1)==1) row_0(n);
else row_1(n);
}
printf(" ");
}
//输出上竖行
if(r>1 && r<n+2)
for(c=0;num[c]>=0;c++){
if(num[c]==5 || num[c]==6) col_l(n);
if(num[c]==1 || num[c]==2 || num[c]==3 || num[c]==7) col_r(n);
if(num[c]==4 || num[c]==8 || num[c]==9 || num[c]==0) col_b(n);
printf(" ");
}
//输出下竖行
if(r>n+2 && r<2*n+3)
for(c=0;num[c]>=0;c++){
if(num[c]==2) col_l(n);
else if(num[c]==0 || num[c]==6 || num[c]==8) col_b(n);
else col_r(n);
printf(" ");
}

printf("\n");
}
}
int main()
{
int i,n,num[9];char temp[9];
while( scanf("%d %s",&n,&temp) && n!=0 ){
memset(num,-1,sizeof(num));
for(i=0;temp[i];i++){
num[i]=temp[i]-'0';
}
display(num,n);
if(n!=0) printf("\n");
}
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值