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. Java Web 设置默认首页

    一.问题描述 这里所谓的默认首页,是指在访问项目根目录时(如 http://localhost:8080/zhx-web/ )展示的页面,通过在web.xml里配置 <welcome-file- ...

  2. Mac 鼠须管 合并词库 简单使用

    之前一直没用过合成词库这功能,有个同步用户数据的选项,点它后,生成一个文件夹,里面就有当前的一些配置,词库之类的 /Users/dfpo/Library/Rime/sync 这样我们就得到了一个装着用 ...

  3. Java统计数据库表中记录数

    public static int count(String txyl_table) {// 获取用户数量 int i = 0;// Store_Information Connection con ...

  4. WPF 检测输入状态

    [DllImport("user32.dll")] static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); pub ...

  5. (转)win32Application和win32ApplicationConsole

    这几天在创建MFC项目时,常常遇到一下两个连接错误,例如: 1. LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _ma ...

  6. cocos基础教程(9)声音和音效

    使用音效引擎 我们可以使用Cocos2d-x自带的CocosDension库来使用声音引擎.CocosDesion实现了简单易用的SimpleAudioEngine类,为了使用它,我们只需引入他的头文 ...

  7. 使用 systemd timer 备份数据库

    导读 主要的Linux发行版都改用systemd 来替代 System V启动方式,其中 systemd timer 能替代 crontab 计划任务的大部分功能.本文介绍了用systemd time ...

  8. Unity3D 4.x 使用Mecanim实现连击

    http://blog.csdn.net/onerain88/article/details/12854817 Unity3D 4.x 版本之后提供了一种新的动画机制Mecanim,虽然目前还支持之前 ...

  9. [ruby on rails] 跟我学之(7)创建数据

    通过form来创建数据,本章节将会涉及内容:创建form,用户重导向,渲染views 和 flash消息. 1. views初步 编辑 app/views/posts/index.html.erb这个 ...

  10. QQ,MSN,Skype在线客服代码

    QQ,MSN,Skype在线客服代码 在网站建设时,为了更好的实施网站的营销型,会用到QQ,MSN等在线交流,以便客户能够快捷方便的联系我们.在这里,提供QQ,MSN的在线客服代码给大家分享: 1.Q ...