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 题号
为什么要分类刷题: 因为刷⼀道算法题需要花⼀两个⼩时甚⾄半天,平时我们还要上课做别的事情,你在⼀段时间内刷算法如果只按照顺序,可能今天遇到了⼀道最短路径的题⽬,弄了半天好不容易看懂了别⼈的代码,以为⾃ ...
随机推荐
- ffmepg 指定RTSP网络连接模式UDP还是TCP
AVFormatContext *formatCtx = NULL; formatCtx = avformat_alloc_context(); AVDictionary* options = NUL ...
- 【周期串】NYOJ-1121 周期串
[题目链接:NYOJ-1121] 例如:abcabcabc 该字符串的长度为9,那么周期串的长度len只可能为{1,3,9},否则就不可能构成周期串. 接下来,就是要在各周期间进行比较.描述不清... ...
- printk 驱动调试
驱动的调试,printk()添加调试信息 printk相当于printf的孪生姐妹,它们一个运行在用户态,另一个则在内核态. 需要包含<linux/device.h>或者<linux ...
- 简单易用的AOP/IOC框架
Source: http://www.codeproject.com/KB/Articles/684613/Working/AopIoc.zip Introduction Supper framewo ...
- 浏览器兼容——jquery的html()不兼容IE
在看着一个页面A,是一个弹出框,用的jquery中的ajax,然后弹出的内容是另一个Div的.而所出现的问题,是在浏览器中都有弹出框,但是只有谷歌和火狐中的弹出框中内容. 当时,我所想到的是另一个问题 ...
- android的R.java
R.java是个好东西,在Android程序开发过程中为你统一管理资源,添加ID,不可谓不犀利.不过有的时候好东西就越是娇贵,在写Android代码的时候,R.java频繁出错,搞得我是身心俱疲.数次 ...
- Android WindowManager 监听返回键及home键
一.监听home键盘,Android Home键系统负责监听,捕获后系统自动处理.有时候,我们需要监听home键处理自己的逻辑,监听方法如下: /** * 监听home键广播 */ private f ...
- [转]Oracle 阳历转农历
CREATE TABLE SolarData ( YearID INTEGER NOT NULL, -- 农历年 DATA ) NOT NULL, -- 农历年对应的16进制数 DataInt INT ...
- js获取浏览器基本信息:document.body.clientWidth/clientHeight/scrollWidth/scrollTop。(转)
js获取浏览器基本信息:document.body.clientWidth/clientHeight/scrollWidth/scrollTop. 分类: js.jquery.ext.js技术2011 ...
- 告别where 1=1 最佳方案分享
已经有2年没有用过where 1=1了,没想到换了家公司后,又让我看到了它.在网络上面搜索了一下,发现没有人提供一个比较好的方案来解决这一问题.很多人说可以让数据库的优化机制去处理,但是,我想对于大部 ...