POJ 1102 LC DISPLAY
来源:互联网 发布:移动网络电视可以分机 编辑:程序博客网 时间:2024/03/29 15:41
#include <iostream>
#define MAX_R 30
#define MAX_C 120
using namespace std;
char res[MAX_R][MAX_C];
int dNum, num;
int digit[10];
int r, c, wide;
void init()
{
//dNum = 0;
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)
res[i][j] = ' ';
}
void getDigit(int temp)
{
if(temp <= 10)
digit[++dNum] = temp;
else
{
getDigit(temp / 10);
digit[++dNum] = temp % 10;
}
}
void fill()
{
int seq, curDigit, startC, endC, midR, tr, tc;
for(seq = 1; seq <= dNum; seq++)
{
curDigit = digit[seq];
startC = (seq - 1) * (wide + 3) + 1;
endC = seq * (wide + 3) - 1;
midR = 2 + wide;
for(tr = 1; tr <= r; tr++)
{
for(tc = startC; tc <= endC; tc++)
{
if(tr == 1 && tc > startC && tc < endC)
{
if(curDigit != 1 && curDigit != 4)
res[tr][tc] = '-';
}
else if(tc == startC && tr > 1 && tr < midR)
{
if(curDigit != 1 && curDigit != 2 && curDigit != 3 && curDigit != 7)
res[tr][tc] = '|';
}
else if(tc == endC && tr > 1 && tr < midR)
{
if(curDigit != 5 && curDigit != 6)
res[tr][tc] = '|';
}
else if(tr == midR && tc > startC && tc < endC)
{
if(curDigit != 1 && curDigit != 7 && curDigit != 0)
res[tr][tc] = '-';
}
else if(tc == startC && tr > midR && tr < r)
{
if(curDigit == 2 || curDigit == 6 || curDigit == 8 || curDigit == 0)
res[tr][tc] = '|';
}
else if(tc == endC && tr > midR && tr < r)
{
if(curDigit != 2)
res[tr][tc] = '|';
}
else if(tr == r && tc > startC && tc < endC)
{
if(curDigit != 1 && curDigit != 4 && curDigit != 7)
res[tr][tc] = '-';
}
}
}
}
}
int main()
{
while(cin>>wide>>num && !(wide == 0 && num == 0))
{
dNum = 0;
getDigit(num);
r = 2 * wide + 3;
c = dNum * (wide + 3) - 1;
init();
fill();
for(int tr = 1; tr <= r; tr++)
{
for(int tc = 1; tc <= c; tc++)
cout<<res[tr][tc];
cout<<endl;
}
cout<<endl;
}
return 0;
}
- POJ 1102 LC DISPLAY
- poj 1102 LC-Display
- POJ 1102 LC-Display
- poj 1102 LC-Display
- POJ 1102 - LC-Display
- poj 1102 LC—display
- POJ 1102 LC-Display 模拟
- poj 1102 LC-Display(模拟)
- POJ 1102 LC Display 笔记
- POJ 1102 LC-Display(模拟题)
- 1102 LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- LC-Display
- FreeBSD下的wget
- POJ 1103 Maze
- php.ini 详解
- javascript数据类型转换
- php-- 避免表单的重复提交
- POJ 1102 LC DISPLAY
- C#编程规范
- windows cmd下的date,time格式的提取!
- Linux 程序设计(应用篇)
- 自己有专职司机了
- 编程求一元二次方程ax2+bx+c=0的根
- QueryInterface函数
- 2009-06-26 TIPTOP
- WebForm开发形式操作时使用层达到遮罩效果