Problem D: LC-Display

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 14  Solved: 3
[Submit][Status][Web Board]

Description

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 ( 0n99, 999, 999) and s is the size in which it shall be displayed ( 1s10). 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

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

HINT

杭电1332


  模拟题。这道题是在控制台中以计算器的显示形式显示指定尺寸大小的一串数字。

  我的做法是提前写好数字的模板(因为尺寸不确定,所以要把数字做成模板),存放在一个三维数组中(数字,行,列)。输入尺寸和数字串后,将数字的模板组合起来,然后解析成指定尺寸的数字输出出来。

My code:

 //这是一道模拟题
//模拟计算器的形式在控制台中输出数字 #include <iostream>
#include <string.h>
using namespace std; int a[][][]=
{
{//
,,,
,,,
,,,
,,,
,,
}
,{//
,,,
,,,
,,,
,,,
,,}
,{//
,,,
,,,
,,,
,,,
,,
}
,{//3
,,,
,,,
,,,
,,,
,,
}
,{//4
,,,
,,,
,,,
,,,
,,
}
,{//5
,,,
,,,
,,,
,,,
,,
}
,{//6
,,,
,,,
,,,
,,,
,,
}
,{//7
,,,
,,,
,,,
,,,
,,
}
,{//8
,,,
,,,
,,,
,,,
,,
}
,{//9
,,,
,,,
,,,
,,,
,,
}
};
/*
0是一个空格
1是size个竖杠
2是size个横杠
3是size个虚横杠
*/
int b[][];
int main()
{
string l;
int size;
while(cin>>size){
cin>>l;
if(size== && l=="") break;
int length=l.length();
//组合数字模板在数组b中
for(int i=;i<=;i++){ //循环行
int f=; //组合数组b的第一个开始赋值
for(int j=;j<=length;j++){ //循环数字
int num=l[j-]-'';
for(int k=;k<;k++){
b[i][f]=a[num][i-][k];
f++;
}
b[i][f]=;
f++;
}
}
/*输出组合好的数字模板
for(int i=1;i<=5;i++){
for(int j=1;j<=3*length+length-1;j++)
cout<<b[i][j];
cout<<endl;
}
*/
//将数字模板解析成数字
//0输出一个空格
//1输出size行竖杠
//2输出size个横杠
//3输出size行空格
int count = ;
for(int i=;i<=;i++){//循环行
for(int j=;j<=*length+length-;j++){
//if(j==3*length+length-1 && b[i][j]==0)
// continue;
if(i%!=){
switch(b[i][j]){
case :
cout<<' ';
break;
case :
for(int k=;k<size;k++)
cout<<'-';
break;
case :
for(int k=;k<size;k++)
cout<<' ';
break;
}
}
else{
switch(b[i][j]){
case :
cout<<' ';break;
case :
for(int k=;k<size;k++)
cout<<' ';
break;
case :
cout<<'|';break;
}
}
}
cout<<endl;
if(i%==){ //如果改行是偶数行,且输出次数再输出一遍
++count; //如果是偶数行,已经输出一遍了,count+1
if(count<size)
--i;
}
else
count=;
}
cout<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

烟大 Contest1024 - 《挑战编程》第一章:入门 Problem D: LC-Display(模拟计算器显示数字)的更多相关文章

  1. ACM YTU 《挑战编程》第一章 入门 Problem E: Graphical Editor

    Description Graphical editors such as Photoshop allow us to alter bit-mapped images in the same way ...

  2. Windows核心编程第一章.错误处理

    Windows核心编程第一章,错误处理. 一丶错误处理 1.核心编程学习总结 不管是做逆向,开始做开发.在Windows下.你都需要看一下核心编程这本书.这本书确实写得很好.所以自己在学习这本书的同时 ...

  3. .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划

    作者:依乐祝 原文地址:https://www.cnblogs.com/yilezhu/p/9977862.html 写在前面 千呼万唤始出来,首先,请允许我长吸一口气!真没想到一份来自28岁老程序员 ...

  4. net core体系-web应用程序-4asp.net core2.0 项目实战(CMS)-第一章 入门篇-开篇及总体规划

    .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划   原文地址:https://www.cnblogs.com/yilezhu/p/9977862.html 写在前面 千呼万唤始出来 ...

  5. Java 面向对象编程——第一章 初识Java

      第一章    初识Java 1.  什么是Java? Java是一种简单的.面向对象的.分布式的.解释的.安全的.可移植的.性能优异的多线程语言.它以其强安全性.平台无关性.硬件结构无关性.语言简 ...

  6. Java学习笔记 第一章 入门<转>

    第一章 JAVA入门 一.基础常识 1.软件开发 什么是软件? 软件:一系列按照特定顺序组织的计算机数据和指令的集合 系统软件:DOS,Windows,Linux 应用软件:扫雷.QQ.迅雷 什么是开 ...

  7. windows核心编程-第一章 对程序错误的处理

    第一章-对程序错误的处理 在开始介绍Microsoft Windows 的特性之前,必须首先了解 Wi n d o w s的各个函数是如何进行错误处理的. 当调用一个Wi n d o w s函数时,它 ...

  8. UNIX环境高级编程--第一章 UNIX基础知识

    第一章 UNIX基础知识 1.2 UNIX体系结构   从严格意义上说,可将操作系统定义为一种软件,它控制计算机硬件资源,提供程序运行环境.我们将这种软件称为内核(kernel),因为 它相对较小,且 ...

  9. 读高性能JavaScript编程 第一章

    草草的看完第一章,虽然看的是译文也是感觉涨姿势了, 我来总结一下: 由于 大多数浏览器都是 single process 处理 ui updatas and js execute 于是产生问题: js ...

随机推荐

  1. Spring实战学习笔记之SpEL表达式

            在Spring XML配置文件中装配Bean的属性和构造参数都是静态的,而在运行期才知道装配的值,就可以使用SpEL实现         SpEL表达式的首要目标是通过计算获得某个值. ...

  2. 升级centos6.5系统的gcc为4.8.5的简易步骤

    Centos6.5_64位升级gcc为4.8.2的简易步骤 一.安装依赖包 yum install texinfo-tex flex zip mpfr-devel libgcc.i686 glibc- ...

  3. shell的执行顺序问题

    &&,||,(),{},& 五个符号的运用 shell脚本执行命令的时候,有时候会依赖于前一个命令是否执行成功.而&&和||就是用来判断前一个命令执行效果的. ...

  4. DedeCMS 5.7 后门漏洞

    简要描述: DedeCMS V5.7 SP1正式版 UTF-8 GBK版本疑似被植入一句话后门 前几日下载并不存在此代码 详细说明: shopcar.class.php被植入一句话@eval(file ...

  5. linux ftp命令(转)

    此命令需要安装ftp, yum install ftp 1. 连接ftp服务器 格式:ftp [hostname| ip-address]a)在linux命令行下输入: ftp 192.168.1.1 ...

  6. du: fts_read 失败: 无法分配内存

    今天在查看一个大的文件时突然报出一个du: fts_read 失败: 无法分配内存的错误. 用 ulimit -a 查看下 core file size (blocks, -c) 0 data seg ...

  7. linux下Nginx服务器安装教程

    序:Nginx服务器安装总结而已,不是教程. 安装的过程中出现了一些问题,原因我的云主机是纯净版,所以很多依赖包都没有.其中安装过程中就发现perl库缺少和openssl库缺少,因此我手动安装的这两款 ...

  8. 关于webstorm的使用编码的问题

    在问storm中,保存的js文件他有编码的问题,所以会导致如果页面上的元素是js文件中赋值的话,那么出现在html中会是乱码的问题,那么这个时候,极度,非常,非常有可能是js的编码的方式问题了~~~~ ...

  9. 繁华模拟赛 Evensgn玩序列

    #include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...

  10. 经典sql语句

    经典SQL语句大全 一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql serv ...