PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解
#include <string>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
string numbers[5][10]={
" - ", " ", " - ", " - ", " ", " - ", " - ", " - ", " - ", " - ",
"| |", " |", " |", " |", "| |", "| ", "| ", " |", "| |", "| |",
" ", " ", " - ", " - ", " - ", " - ", " - ", " ", " - ", " - ",
"| |", " |", "| ", " |", " |", " |", "| |", " |", "| |", " |",
" - ", " ", " - ", " - ", " ", " - ", " - ", " ", " - ", " - ",
};
const int MAX_LEN=10;
int num[MAX_LEN];
//return number length
int fill_num(int n)
{
memset(num, 0, sizeof(num));
int i=0;
do
{
num[i++]=n%10;
n/=10;
}while(n!=0);
reverse(num, num+i);
return i;
}
void cout_a_row(int s, string n)
{
cout<<n[0];
for(int i=0;i<s;i++)
cout<<n[1];
cout<<n[2];
}
void print_num(int s, int n)
{
int len=fill_num(n);
//cout<<len<<endl;
for(int row=0;row<(3+2*s);row++)
{
//输出各个数字的一行
for(int i=0;i<len;i++)
{
int real_row;
//head
if(row==0)
{
real_row=0;
}
//head-mid
if(row>0 && row<(3+2*s)/2)
{
real_row=1;
}
//mid
if(row==(3+2*s)/2)
{
real_row=2;
}
if(row>(3+2*s)/2 && row<(3+2*s-1))
{
real_row=3;
}
//tail
if(row==(3+2*s-1))
{
real_row=4;
}
cout_a_row(s, numbers[real_row][num[i]]);
(i==len-1)?(cout<<endl):(cout<<" ");
}
}
cout<<endl;
}
int main()
{
#if 0
print_num(1, 1234567890);
print_num(3, 1234567890);
print_num(5, 1234567890);
print_num(7, 1234567890);
#endif
int s,num;
while(cin>>s>>num, s||num)
{
print_num(s, num);
}
return 0;
}
PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解的更多相关文章
- PC/UVa 题号: 110106/10033 Interpreter (解释器)题解 c语言版
, '\n'); #include<cstdio> #include<iostream> #include<string> #include<algorith ...
- PC/UVa 题号: 110105/10267 Graphical Editor (图形化编辑器)题解
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
- PC/UVa 题号: 110101/100 The 3n+1 problem (3n+1 问题)
The 3n + 1 problem Background Problems in Computer Science are often classified as belonging to a ...
- uva题库爬取
每次进uva都慢的要死,而且一步一步找到自己的那个题目简直要命. 于是,我想到做一个爬取uva题库,记录一下其中遇到的问题. 1.uva题目的链接是一个外部的,想要获取https资源,会报出SNIMi ...
- 天大acm 题号1002 Maya Calendar
Description 上周末,M.A. Ya教授对古老的玛雅有了一个重大发现.从一个古老的节绳(玛雅人用于记事的工具)中,教授发现玛雅人使用了一个一年有365天的叫做Haab的历法.这 个Haab历 ...
- The Trip PC/UVa IDs: 110103/10137, Popularity: B, Success rate: average Level: 1
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
- hdu&&poj搜索题题号
搜索 hdu1067 哈希 hdu1401 双向搜索 hdu1430 哈希 hdu1667 跌搜+启发式函数 hdu1685 启发式搜索 hdu1813 启发式搜索 hdu1885 状态压缩搜索 hd ...
- [Swust OJ 666]--初来乍到(题号都这么溜~~,递归,找规律)
题目链接:http://acm.swust.edu.cn/problem/0666/ Time limit(ms): 1000 Memory limit(kb): 65535 Descriptio ...
- PAT DFS,BFS,Dijkstra 题号
为什么要分类刷题: 因为刷⼀道算法题需要花⼀两个⼩时甚⾄半天,平时我们还要上课做别的事情,你在⼀段时间内刷算法如果只按照顺序,可能今天遇到了⼀道最短路径的题⽬,弄了半天好不容易看懂了别⼈的代码,以为⾃ ...
随机推荐
- python - 回溯继承树 - 自己实现
# -*- coding: utf-8 -*- class test(object): pass class test1(test): pass class test2(test1): pass pr ...
- Java [Leetcode 122]Best Time to Buy and Sell Stock II
题目描述: Say you have an array for which the ith element is the price of a given stock on day i. Design ...
- ViewPager设置 缓存个数、页卡间距、数据更新
在使用ViewPager常用设置 1)mViewPager.setOffscreenPageLimit(2);//设置缓存view 的个数(实际有3个,缓存2个+正在显示的1个)2)mViewPage ...
- MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql
目录(?)[-] 一MyBatis简介与配置MyBatisSpringMySql MyBatis简介 MyBatisSpringMySql简单配置 搭建Spring环境 建立MySql数据库 搭建My ...
- linux 标准 GPIO 操作
Linux 提供了GPIO 操作的 API,具体初始化及注册函数在 driver/gpio/lib_gpio.c 中实现. #include int gpio_request(unsigne ...
- C语言内存地址基础
来源:http://blog.jobbole.com/44845/ 从计算机内存的角度思考C语言中的一切东东,是挺有帮助的.我们可以把计算机内存想象成一个字节数组,内存中每一个地址表示 1 字节.比方 ...
- 转载: Vim 练级攻略
转自:http://coolshell.cn/articles/5426.html 酷壳 vim的学习曲线相当的大(参看各种文本编辑器的学习曲线),所以,如果你一开始看到的是一大堆VIM的命令分类, ...
- Delphi RICHEDIT中插入图象
unit InsRich;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- Hadoop 学习之 FAQ
在Hadoop的学习与使用过程中同样如此.这里为大家分享Hadoop集群设置中经常出现的一些问题,以下为译文: 1.Hadoop集群可以运行的3个模式? 单机(本地)模式 伪分布式模式 全分布式模式 ...
- 【原】Storm Tutorial
Storm入门教程 1. Storm基础 Storm Storm主要特点 Storm基本概念 Storm调度器 Storm配置 Guaranteeing Message Processing(消息处理 ...