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 题号
为什么要分类刷题: 因为刷⼀道算法题需要花⼀两个⼩时甚⾄半天,平时我们还要上课做别的事情,你在⼀段时间内刷算法如果只按照顺序,可能今天遇到了⼀道最短路径的题⽬,弄了半天好不容易看懂了别⼈的代码,以为⾃ ...
随机推荐
- 当前,思路+进展+idea+下一步要做的工作
1.在phy+版本中,downweighting操作后,是如何计算相关系数的. 2.这里的算法的自适应,体现在哪里?3.在引入PCA之后,这里有一个维度的选择的过程,这个标准是如何定义的? 4.在NP ...
- windows 下使用 MinGW + msys 编译 ffmpeg
本文参考了网络上的不少文章,但由于版本环境的问题参考文章并不能直接指导编译,本文吸收多方经验,并在自己多次编译实验的基础上写成,欢迎转载,请注名出处. FFmpeg是在Linux平台下开发的,但 ...
- 转载RabbitMQ入门(5)--主题
主题(topic) (使用Java客户端) 在先前的指南中我们改进了我们的日志系统.取代使用fanout类型的交易所,那个仅仅有能力实现哑的广播,我们使用一个direct类型的交易所,获得一个可以有选 ...
- https实现安全传输的流程
HTTPS简介 HTTPS其实是有两部分组成:HTTP + SSL / TLS,也就是在HTTP上又加了一层处理加密信息的模块.服务端和客户端的信息传输都会通过TLS进行加密,所以传输的数据都是加密后 ...
- Ejabberd源码解析前奏--配置
一.基本配置 配置文件将在你第一次启动ejabberd时加载,从该文件中获得的内容将被解析并存储到内部的ejabberd数据库中,以后的配置将从数据库加载,并且任何配置文件里的命令都会被添加到 ...
- C# 如何以参数的形式调用.exe程序
System.Diagnostics.Process.Start("程序的路径", "参数1 参数2");第一个参数是aaa.exe 的路径,第二个参数是用空格 ...
- java移动/赋值文件 copy/move file
public class FileAccess { public static boolean Move(File srcFile, String destPath) { // Destination ...
- HDU 5768 Lucky7 容斥原理+中国剩余定理(互质)
分析: 因为满足任意一组pi和ai,即可使一个“幸运数”被“污染”,我们可以想到通过容斥来处理这个问题.当我们选定了一系列pi和ai后,题意转化为求[x,y]中被7整除余0,且被这一系列pi除余ai的 ...
- OpenGL超级宝典第5版&&基础渲染
1.OpenGL查询拓展机制是否被支持 gltools函数库: int gltIsExtSupported(const char *extension) { #ifndef OPENGL_ES GLi ...
- 修复duilib库UISlider控件的4个bug
转载级请注明原出处,谢谢~· 昨天封装好一个音频类,我在为dulib做音频播放demo时发现了一些问题,由CSliderUI控件导致的,进而发现了这个控件的好几样不足,他无法满 足我们做一个播放器的进 ...