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 题号
为什么要分类刷题: 因为刷⼀道算法题需要花⼀两个⼩时甚⾄半天,平时我们还要上课做别的事情,你在⼀段时间内刷算法如果只按照顺序,可能今天遇到了⼀道最短路径的题⽬,弄了半天好不容易看懂了别⼈的代码,以为⾃ ...
随机推荐
- 【C#学习笔记】检测进程是否存在并关闭
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- TCP协议的一些问题
1 连接握手三次 解释1:已失效的连接请求报文段 情况下如下:client发出的第一个连接请求报文段并没有丢失,而是在某个网络结点长时间的滞留了,以致延误到连接释放以后的某个时间才到达server.本 ...
- LeetCode: Maximum Product Subarray && Maximum Subarray &子序列相关
Maximum Product Subarray Title: Find the contiguous subarray within an array (containing at least on ...
- directdraw显示yuv视频,出现屏保时,yuv显示不出来,表面丢失
原因是: DDrawSurface 丢失, DDraw表面在很多情况下都会丢失(如:启动其他全屏独占程序,屏保,或锁屏时), 表面丢失其实就是表面所使用的内存或显存被DirectDraw系统释放, 分 ...
- shell 删除日志
一般线上服务的日志都是采用回滚的防止,写一定数量的日志 或是有管理工具定期去转移老旧日志 前几天删除一个测试环境的日志,只保留两天的日志,结果把正在写的日志都给删掉了,不得不重启了服务,经过这一次的错 ...
- js基础学习第一天(关于DOM和BOM)一
关于BOM和DOM BOM 下面一幅图很好的说明了BOM和DOM的关系 BOM提供了一些访问窗口对象的一些方法,我们可以用它来移动窗口位置,改变窗口大小,打开新窗口和关闭窗口,弹出对话框,进行导航以及 ...
- 2014年acm亚洲区域赛·鞍山站
今天北京赛站的比赛也结束了···看了一天的直播之后意识到鞍山站的比赛都过去了一个多月了···这一个月比较萎靡···整天都在睡觉写报告画工图中度过··· 鞍山比哈尔滨还是暖和很多的···就是山上有奇怪的 ...
- HDU 4609 3-idiots FFT+容斥
一点吐槽:我看网上很多分析,都是在分析这个题的时候,讲了半天的FFT,其实我感觉更多的把FFT当工具用就好了 分析:这个题如果数据小,统计两个相加为 x 的个数这一步骤(这个步骤其实就是求卷积啊),完 ...
- <转>如何测试一个杯子
在软件测试的面试中, 经常会碰到类似的问题. 比如:如何测试一个杯子, 或者如何测试一只笔. 要求你设计20个以上的test case. 这类的面试题目,是考察面试者是否熟悉各种软件测试方法, 设计t ...
- JS数组(Array)操作汇总
1.去掉重复的数组元素.2.获取一个数组中的重复项.3.求一个字符串的字节长度,一个英文字符占用一个字节,一个中文字符占用两个字节.4.判断一个字符串中出现次数最多的字符,统计这个次数.5.数组排序. ...