PC/UVa 110104/706 LC-Display
来源:互联网 发布:python日期转字符串 编辑:程序博客网 时间:2024/04/26 19:48
模拟题:
观察
将这些“-”和“|”都写到数组里,令s=1
注意1当数字为“1”的时候要讲“|”写到最后一个也就是第s+2个,
2 每个数字之间隔一个空格
3 每个整数之后有一个空行
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int s;
char str[15];
int n[15];
int len;
char num[40][50]={" - - - - - - - - ",
"| | | | || || | || || |",
" - - - - - - - ",
"| | | | | | || | || | |",
" - - - - - - - "};
void change()
{
int i;
len=strlen(str);
for(i=0;i<len;i++)
{
n[i]=str[i]-'0';
}
}
void printfun(int num_i,int num_k)
{
int i;
printf("%c",num[num_i][num_k]);
for(i=1;i<=s;i++)
printf("%c",num[num_i][num_k+1]);
printf("%c",num[num_i][num_k+2]);
}
void print1(int i,int k)
{
int t;
for(t=1;t<=s+1;t++)
printf(" ");
printf("%c",num[i][k+1]);
}
void solve()
{
int i,j,k;
int lb=s+2;
int la=2*s+3;
for(i=0;i<la;i++)//整数一共la行
{
for(j=0;j<len;j++)//对每个整数的第i行进行输出
{
k=n[j]*3;
if(n[j]!=1)
{
if(i==0)
printfun(0,k);
else if(i==la/2)
printfun(2,k);
else if(i==la-1)
printfun(4,k);
else if(i>=1&&i<=s)
printfun(1,k);
else
printfun(3,k);
}
else //特别考虑当数字为1的时候
{
if(i==0)
print1(0,k);
else if(i==la-1)
print1(4,k);
else if(i==la/2)
print1(2,k);
else if(i>=1&&i<=s)
print1(1,k);
else print1(3,k);
}
if(j<len-1)
printf(" ");
}
printf("\n");
}
}
int main()
{
while(scanf("%d%s",&s,str)!=EOF)
{
if(s==0&&strcmp(str,"0")==0)
break;
change();
solve();
printf("\n");
}
return 0;
}
- PC/UVa 110104/706 LC-Display
- UVa 706 Problem: LC-Display (PC 110104)
- uva 706 LC-Display
- UVa 706 LC-Display
- uva 706 LC-Display
- UVA 706 LC-Display
- 模拟 UVa 706 LC-Display
- PC 110104 LC-Display 液晶显示屏//字符串 水题
- UVa Problem Solution: 706 - LC-Display
- UVa Problem 706 LC-Display (液晶显示屏)
- UVa Problem 706 LC-Display (液晶显示屏)
- 110104 LC-Display
- 706 - LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- mx53 camera s5k5bbgx驱动分析
- winform项目的app.config和exe.config文件
- 相关书籍
- AppScale
- 基于SOM的多目标优化
- PC/UVa 110104/706 LC-Display
- mx53 camera HAL preview(接口层)
- extjs panel动态添加button
- QTP中关于smart identification的疑问
- 现实迷途 第五章 新春大计
- C#.net udp点对点聊天程序
- wmi 引用Management获取CPU、内存、硬盘等系统及硬件信息
- ITU speech codec
- 随机布尔神经网络(RBN)简介与资源