首页 > 其他分享 >UVa 706 / POJ 1102 LCD Display (模拟)

UVa 706 / POJ 1102 LCD Display (模拟)

时间:2023-04-12 13:05:14浏览次数:54  
标签:code putchar -- 706 len --- int LCD 1102


706 - LCD Display

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=647

http://poj.org/problem?id=1102

A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed, because he liked the LC-display of his calculator so much. So you decide to write a program that displays numbers in an LC-display-like style on his computer.

Input

The input file contains several lines, one for each number to be displayed. Each line contains two integerssn ( 

), where n is the number to be displayed and s is the size in which it shall be displayed.

The input file will be terminated by a line containing two zeros. This line should not be processed.

Output

Output the numbers given in the input file in an LC-display-style using s ``-'' signs for the horizontal segments and s ``|'' signs for the vertical ones. Each digit occupies exactly s+2 columns and 2s+3 rows. (Be sure to fill all the white space occupied by the digits with blanks, also for the last digit.) There has to be exactly one column of blanks between two digits.

Output a blank line after each number. (You will find a sample of each digit in the sample output.)

Sample Input


2 123453 67890
0 0


Sample Output


--   --        --    |    |    | |  | | 
   |    |    | |  | | 
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        -- 

 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   --- 
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---



先写个常量字符串数组~


完整代码:

/*UVa: 0.032s*/
/*POJ: 0ms,160KB*/

#include <cstdio>
#include <cstring>
const char code[5][31] =
{
	" -     -  -     -  -  -  -  - ",
	"| |  |  |  || ||  |    || || |",
	"       -  -  -  -  -     -  - ",
	"| |  ||    |  |  || |  || |  |",
	" -     -  -     -  -     -  - ",
};

int s;
char n[20];

inline void print(int t , int len)
{
	for (int i = 0; i < len; i++)
	{
		int a = n[i] & 15;
		if (i) putchar(' ');
		putchar(code[t][a * 3]);
		for (int j = 0; j < s; j++)
			putchar(code[t][a * 3 + 1]);
		putchar(code[t][a * 3 + 2]);
	}
	putchar('\n');
}

int main(void)
{
	int len;
	while (scanf("%d%s", &s, n), s)
	{
		len = strlen(n);
		for (int i = 0; i < 5; i++)///从上往下打印
		{
			if (i == 1 || i == 3)
				for (int j = 0; j < s; j++)
					print(i, len);
			else
				print(i, len);
		}
		putchar('\n');
	}
	return 0;
}


Source


Mid-Central European Regional Contest 1999

标签:code,putchar,--,706,len,---,int,LCD,1102
From: https://blog.51cto.com/u_5535544/6185482

相关文章

  • LCD01-基本概念
           1.亚像素控制灰阶显示不同颜色2.利用视觉暂留效应通过控制像素显示时间来显示不同颜色   液晶显示器(LCD)是一种数字显示技术,其工作原理是通过电场控制液晶分子的方向来调节光的偏振方向,从而实现显示效果。在液晶显示器中,偏光片发挥着至关重要的作......
  • UVA - 10706 Number Sequence 子序列
    #include<cstdio>#include<cmath>#include<algorithm>usingnamespacestd;constintmaxn=32761;longlongS[maxn];//存放的是S1,S2,到SK的和,S[5]表示了S1到S4的和,当数字变化到K的时候,一共有多少个字数了intborder[9]={0,1,10,100,1000,10000,100000,1000000,10000000......
  • 3d打印 LCD2004/12864显示不清楚 正面看不清 背光太强 的问题
    第一次买相关配件,没经验解决方法:背面有一个调节显示电压的旋钮。背光强调低点,字体弱,调高点。背部调节电压的旋钮:   原因:用专业语言就是液晶屏鬼影和字浅,鬼影是本不该显示的内容显示出来了,一般是电路供给液晶屏的电压高于液晶屏的工作电压造成的;字浅就是液晶屏上的内容颜......
  • STM32 FSMC的 NOR FLASH B模式模拟LCD 8080时序
    STM32 FSMC:FSMC(FlexibleStaticMemoryController):翻译为:灵活的静态存储管理器。可管理的存储类型包括:NORFLASH 和 SRAMNANDFLASHPC Card(PC卡,不知道是什么东西)具体功能是将外部的存储设备映射为内部地址,可以用程序访问这些地址,间接地,由FSMC 自动产生相应时序,......
  • 联芸mas0902固态使用量产工具的开卡方法,mas0902/mas1102开卡软件教程
    MAS0902是一款固态存储器芯片,一般固态硬盘损坏的情况下才需要量产,在量产过程中,需要从量产部落网下载对应主控型号和闪存颗粒类型的量产工具后,使用量产工具来对芯片进行初始化和测试。以下是MAS0902固态使用量产工具的开卡方法:1.首先,将采用MAS0902芯片的固态硬盘短接ROM孔后,连......
  • 野火书籍《STM32库开发指南》 第26章LCD代码勘误
     第26章LCD代码,P303代码写错。原来的代码写错,因为是D/CX引脚,高电平(1)意味着数据,低电平(0)意味着命令:#defineFSMC_Addr_ILI9341_CMD((uint32_t))0x60020000#defineFSMC_Addr_ILI9341_DATA((uint32_t))0x60000000因此应该将两个宏定义对换。正确的为:#defineFS......
  • NIOS控制LCD16207 IP核
    NIOS控制LCD16207IP核在Quartus中集成了一个qsys工具,用于搭建sopc系统。qsys中提供了一个LCD16207的ip核,该ip核可以驱动LCD1602,在bsp设置中选择lcd16207为标准输出,即可通过printf()函数将字符输出到LCD上。查阅官方手册《EmbeddedPeripheralsIPUserGuide》,手册中说道:TheL......
  • LCD液晶驱动/LED数码管驱动IC原厂;单键/多键触摸触控芯片厂家-VINKA/永嘉微电,FAE技术支
        深圳市永嘉微电科技有限公司成立于2013年,是一家以集成电路开发、测试、销售为主的高科技公司。公司的产品涵盖触控、健康量测、工控仪表、航模、小家电,车用及安全监控与智能家居等应用领域,此外还提供各种触摸、LCD/LED驱动、电源管理、MCU及各类控制芯片。   ......
  • 【永嘉原厂技术支持】超低功耗LCD液晶段码屏显示驱动IC-VKL076 SSOP28,19*4 76点阵,超低
    VKL076概述:VKL076是一个点阵式存储映射的LCD驱动器,可支持最大76点(19SEGx4COM)的LCD屏。单片机可通过I2C接口配置显示参数和读写显示数据,可配置4种功耗模式,也可通过关显示......
  • VKL060 SSOP24 LCD液晶段码屏显示驱动IC超低功耗/低工作电流/超省电
    型号:VKL060品牌:永嘉微电/VINKA封装形式:SSOP24年份:新年份工程服务,技术支持!VKL060概述: VKL060是一个点阵式存储映射的LCD驱动器,可支持最大60点(15SEGx4COM)的LCD屏。单片机可......