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 题号
为什么要分类刷题: 因为刷⼀道算法题需要花⼀两个⼩时甚⾄半天,平时我们还要上课做别的事情,你在⼀段时间内刷算法如果只按照顺序,可能今天遇到了⼀道最短路径的题⽬,弄了半天好不容易看懂了别⼈的代码,以为⾃ ...
随机推荐
- 【转】iOS中定时器NSTimer的使用
原文网址:http://www.cnblogs.com/zhulin/archive/2012/02/02/2335866.html 1.初始化 + (NSTimer *)timerWithTimeI ...
- 在android中进行视频的分割
最近项目有个需求要对录制的视频进行分割,查了很多资料,看到ffmpeg可以对视频进行分割.上网找到别人基于android的开源ffmpeg,终于编译成功ffmpeg.so.但是要使用的话还要查ffmp ...
- HDU 5407 CRB and Candies
题意:给一个正整数k,求lcm((k, 0), (k, 1), ..., (k, k)) 解法:在oeis上查了这个序列,得知答案即为lcm(1, 2, ..., k + 1) / (k + 1),而 ...
- hdu 5407 CRB and Candies(组合数+最小公倍数+素数表+逆元)2015 Multi-University Training Contest 10
题意: 输入n,求c(n,0)到c(n,n)的所有组合数的最小公倍数. 输入: 首行输入整数t,表示共有t组测试样例. 每组测试样例包含一个正整数n(1<=n<=1e6). 输出: 输出结 ...
- XtraGrid的若干种用法 z
支持多种类型的数据集合作为数据源 XtraGrid与传统的DataGridView一样,支持多种类型作为其数据源.下面例子是将DataTable, List<T>和数组分别绑定到XtraG ...
- Python学习之eventlet.greenpool
该模块提供对 greenthread 池的支持. greenthread 池提供了一定数量的备用 greenthread ,有效限制了孵化 greenthread 过多导致的内存不足,当池子中没有足够 ...
- bzoj 3732 Network(最短路+倍增 | LCT)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3732 [题意] 给定一个无向图,处理若干询问:uv路径上最长的边最小是多少? [思路一 ...
- 自定义Camera综述(一般步骤、注意事项、遇到的难题<【内存溢出问题】>、像素参考)
一般步骤: 1. 检查和访问Camera:创建代码来检查Camera和所申请访问的存在性: 2. 创建一个预览类:继承SurfaceView来创建一个Camera的预览类,并实现SurfaceHold ...
- Sqlserver作业-手把手带你体验
所谓Sql Server作业就是按照规定的时间执行指定的脚本,如果在SQL Server 里需要定时或者每隔一段时间执行某个存储过程或3200字符以内的SQL语句时,可以用管理-SQL Server代 ...
- Hadoop MapReduce程序中解决第三方jar包问题方案
hadoop怎样提交多个第三方jar包? 方案1:把所有的第三方jar和自己的class打成一个大的jar包,这种方案显然笨拙,而且更新升级比较繁琐. 方案2: 在你的project里面建立一个lib ...