706 - LC-Display
来源:互联网 发布:知乎 欧美系护肤品 编辑:程序博客网 时间:2024/03/29 17:34
题目
Time limit: 3.000 seconds
pdf题目
解题思路
1.把一个数字看成是5*3的矩阵,提前算好10个数字的打印模式,最后根据输入一行一行地输出
2.设n是打印数值的位数,那么时间复杂度是Θ(n),空间复杂度是O(1)
通过代码
<pre name="code" class="cpp">#include<stdio.h>#include<string.h>bool h1[10]={1,0,1,1,0,1,1,1,1,1};bool h2[10]={0,0,1,1,1,1,1,0,1,1};bool h3[10]={1,0,1,1,0,1,1,0,1,1};bool v11[10]={1,0,0,0,1,1,1,0,1,1};bool v12[10]={1,1,1,1,1,0,0,1,1,1};bool v21[10]={1,0,1,0,0,0,1,0,1,0};bool v22[10]={1,1,0,1,1,1,1,1,1,1};void print_1h(char n[],int s,bool h[]){for(int i=0;i<strlen(n);++i){printf(" ");for(int j=0;j<s;++j)if(h[n[i]-'0'])printf("-");elseprintf(" ");printf(" ");if(i<strlen(n)-1)printf(" ");}printf("\n");}void print_3v(char n[],int s,bool vl[],bool vr[]){for(int j=0;j<s;++j){for(int i=0;i<strlen(n);++i){if(vl[n[i]-'0'])printf("|");elseprintf(" ");for(int k=0;k<s;++k)printf(" ");if(vr[n[i]-'0'])printf("|");elseprintf(" ");if(i<strlen(n)-1)printf(" ");}printf("\n");}}int main(){int s;char n[10];#ifdef DEBUG freopen("in","r",stdin); freopen("out","w",stdout);#endifwhile(true){scanf("%d%s",&s,n);if(s==0)break;//print h1print_1h(n,s,h1);//print v11 blank v12print_3v(n,s,v11,v12);//print h2print_1h(n,s,h2);//print v21 blank v22print_3v(n,s,v21,v22);//print h3print_1h(n,s,h3);printf("\n");}return 0;}
运行截图
1 0
- uva 706 LC-Display
- UVa 706 LC-Display
- uva 706 LC-Display
- 706 - LC-Display
- UVA 706 LC-Display
- 模拟 UVa 706 LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- UVa Problem Solution: 706 - LC-Display
- UVa Problem 706 LC-Display (液晶显示屏)
- PC/UVa 110104/706 LC-Display
- UVa Problem 706 LC-Display (液晶显示屏)
- 设计模式读书笔记之建造者模式(Builder)
- 资源 genymotion-2.6.0-vbox.exe不能下载的解决方案
- simhash算法
- 写论文第三天:绘制初步策略的评估结果
- ANDROID webview加载本地内容代码
- 706 - LC-Display
- uva 497 Strategic Defense Initiative
- 设计模式读书笔记之外观模式/门面模式(Facade)
- 这些情况,去面试就是浪费时间!
- 第二章 知识图谱——机器大脑中的知识库
- 树状数组
- hdu1867A + B for you again(kmp)
- CSDN看的一些 C艹笔试题
- java集合框架11——TreeMap和源码分析(二)