假期训练——OpenJ_Bailian - 2745 显示器 模拟
2017-01-24 22:43
483 查看
你的一个朋友买了一台电脑。他以前只用过计算器,因为电脑的显示器上显示的数字的样子和计算器是不一样,所以当他使用电脑的时候会比较郁闷。为了帮助他,你决定写一个程序把在电脑上的数字显示得像计算器上一样。
Input输入包括若干行,每行表示一个要显示的数。每行有两个整数s和n (1 <= s <= 10, 0 <= n <= 99999999),这里n是要显示的数,s是要显示的数的尺寸。
如果某行输入包括两个0,表示输入结束。这行不需要处理。
Output显示的方式是:用s个'-'表示一个水平线段,用s个'|'表示一个垂直线段。这种情况下,每一个数字需要占用s+2列和2s+3行。另外,在两个数字之间要输出一个空白的列。在输出完每一个数之后,输出一个空白的行。注意:输出中空白的地方都要用空格来填充。
Sample Input
Sample Output
Hint数字(digit)指的是0,或者1,或者2……或者9。
数(number)由一个或者多个数字组成。
根据每个数字特征列出个数组,然后输出就好了。。
注意为0 的时候。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
//0 1 2 3 4 5 6 7 8 9
int a1[10] ={1,0,1,1,0,1,1,1,1,1};
int ble[10]={1,0,0,0,1,1,1,0,1,1};
int bri[10]={1,1,1,1,1,0,0,1,1,1};
int c1[10] ={0,0,1,1,1,1,1,0,1,1};
int dle[10]={1,0,1,0,0,0,1,0,1,0};
int dri[10]={1,1,0,1,1,1,1,1,1,1};
int e1[10] ={1,0,1,1,0,1,1,0,1,1};
vi num;
int s,n;
int main()
{
while(cin>>s>>n)
{
num.clear();
if(s==0&&n==0)
{
break;
}
int t = n;
if(t==0)
num.push_back(0);
while(t)
{
num.push_back(t%10);
t/=10;
}
for(int i=num.size()-1;i>=0;i--)
{
cout<<" ";
if(a1[num[i]])
rep(k,0,s) cout<<"-";
else
rep(k,0,s) cout<<" ";
cout<<" ";
cout<<" ";
}
cout<<endl;
rep(i,0,s)
{
for(int k=num.size()-1;k>=0;k--)
{
if(ble[num[k]])
cout<<"|";
else
cout<<" ";
rep(k,0,s)
cout<<" ";
if(bri[num[k]])
cout<<"|";
else
cout<<" ";
cout<<" ";
}
cout<<endl;
}
for(int i=num.size()-1;i>=0;i--)
{
cout<<" ";
if(c1[num[i]])
rep(k,0,s) cout<<"-";
else
rep(k,0,s) cout<<" ";
cout<<" ";
cout<<" ";
}
cout<<endl;
rep(i,0,s)
{
for(int k=num.size()-1;k>=0;k--)
{
if(dle[num[k]])
cout<<"|";
else
cout<<" ";
rep(k,0,s)
cout<<" ";
if(dri[num[k]])
cout<<"|";
else
cout<<" ";
cout<<" ";
}
cout<<endl;
}
for(int i=num.size()-1;i>=0;i--)
{
cout<<" ";
if(e1[num[i]])
rep(k,0,s) cout<<"-";
else
rep(k,0,s) cout<<" ";
cout<<" ";
cout<<" ";
}
cout<<endl;
cout<<endl;
}
return 0;
}
Input输入包括若干行,每行表示一个要显示的数。每行有两个整数s和n (1 <= s <= 10, 0 <= n <= 99999999),这里n是要显示的数,s是要显示的数的尺寸。
如果某行输入包括两个0,表示输入结束。这行不需要处理。
Output显示的方式是:用s个'-'表示一个水平线段,用s个'|'表示一个垂直线段。这种情况下,每一个数字需要占用s+2列和2s+3行。另外,在两个数字之间要输出一个空白的列。在输出完每一个数之后,输出一个空白的行。注意:输出中空白的地方都要用空格来填充。
Sample Input
2 12345 3 67890 0 0
Sample Output
-- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- ---
Hint数字(digit)指的是0,或者1,或者2……或者9。
数(number)由一个或者多个数字组成。
根据每个数字特征列出个数组,然后输出就好了。。
注意为0 的时候。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
//0 1 2 3 4 5 6 7 8 9
int a1[10] ={1,0,1,1,0,1,1,1,1,1};
int ble[10]={1,0,0,0,1,1,1,0,1,1};
int bri[10]={1,1,1,1,1,0,0,1,1,1};
int c1[10] ={0,0,1,1,1,1,1,0,1,1};
int dle[10]={1,0,1,0,0,0,1,0,1,0};
int dri[10]={1,1,0,1,1,1,1,1,1,1};
int e1[10] ={1,0,1,1,0,1,1,0,1,1};
vi num;
int s,n;
int main()
{
while(cin>>s>>n)
{
num.clear();
if(s==0&&n==0)
{
break;
}
int t = n;
if(t==0)
num.push_back(0);
while(t)
{
num.push_back(t%10);
t/=10;
}
for(int i=num.size()-1;i>=0;i--)
{
cout<<" ";
if(a1[num[i]])
rep(k,0,s) cout<<"-";
else
rep(k,0,s) cout<<" ";
cout<<" ";
cout<<" ";
}
cout<<endl;
rep(i,0,s)
{
for(int k=num.size()-1;k>=0;k--)
{
if(ble[num[k]])
cout<<"|";
else
cout<<" ";
rep(k,0,s)
cout<<" ";
if(bri[num[k]])
cout<<"|";
else
cout<<" ";
cout<<" ";
}
cout<<endl;
}
for(int i=num.size()-1;i>=0;i--)
{
cout<<" ";
if(c1[num[i]])
rep(k,0,s) cout<<"-";
else
rep(k,0,s) cout<<" ";
cout<<" ";
cout<<" ";
}
cout<<endl;
rep(i,0,s)
{
for(int k=num.size()-1;k>=0;k--)
{
if(dle[num[k]])
cout<<"|";
else
cout<<" ";
rep(k,0,s)
cout<<" ";
if(dri[num[k]])
cout<<"|";
else
cout<<" ";
cout<<" ";
}
cout<<endl;
}
for(int i=num.size()-1;i>=0;i--)
{
cout<<" ";
if(e1[num[i]])
rep(k,0,s) cout<<"-";
else
rep(k,0,s) cout<<" ";
cout<<" ";
cout<<" ";
}
cout<<endl;
cout<<endl;
}
return 0;
}
相关文章推荐
- 【codeforces 553E】 Kyoya and Train
- smarty报错:lexing failed because a rule matched an empty string解决方案
- apns返回的handShake_failure错误
- A1106. Lowest Price in Supply Chain (25)
- RAID技术
- Tail Recusive
- 人工智能之我见
- 或许我们就是人工智能
- AIX 7.1.0.0 硬盘克隆并移植
- foxmail收取163企业邮箱设置,不能直接用foxmail默认的配置,否则一直提示帐号密码错误
- 用友善提供的4.5.1解压后,运行/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc -v出错
- 用友善提供的4.5.1解压后,运行/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc -v出错
- HDU 1702 ACboy needs your help again!
- [Codeforces Round #354 DIV2E (CF676E)] The Last Fight Between Human and AI
- 336. Palindrome Pairs
- CodeForces - 272C Dima and Staircase (线段树区间更新)
- LISTENING、ESTABLISHED、TIME_WAIT及CLOSE_WAIT 端口状态说明
- youcompleteme unavailable: no module named "future"解决
- keil出現 Error: Flash Download failed: - "Cortex-M3" 問題解決
- hdu 3487 Play with Chain(splay区间剪切,翻转)