http://sdjzu.acmclub.com/index.php?app=problem_title&assignment_id=1014&problem_id=1027
题目描述
电子钟用四个数字来表示时间,每个数字的尺寸为3*3,用于表示数字的字符包括‘|’、‘_’和空格。
现在给你当前的时间,请你告诉我们电子钟是如何展示这个时间的。
电子钟显示的数字样式如下:
_ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_|
输入格式
输入包含多组测试数据。每组输入包含4个整数,表示当前时间。
输出
对于每组输入,输出由电子钟显示出来的时间样式。
样例输入
1 2 5 6
2 3 4 2
样例输出
_ _ _
| _||_ |_
||_ _||_|
_ _ _
_| _||_| _|
|_ _| ||_
分析:
#include<iostream>
using namespace std;
int main()
{
int b[4];
while(cin>>b[0]>>b[1]>>b[2]>>b[3])
{
for(int i=1; i<4; i++)
{
if(i==1)
{
for(int j=0; j<4; j++)
{
if(b[j]==1||b[j]==4)
cout<<" ";
else
cout<<" _ ";
}
}
if(i==2)
{
for(int j=0; j<4; j++)
{
if(b[j]==0)
cout<<"| |";
else if(b[j]==1||b[j]==7)
cout<<" |";
else if(b[j]==2||b[j]==3)
cout<<" _|";
else if(b[j]==5||b[j]==6)
cout<<"|_ ";
else
cout<<"|_|";
}
}
if(i==3)
{
for(int j=0; j<4; j++)
{
if(b[j]==2)
cout<<"|_ ";
else if(b[j]==1||b[j]==4||b[j]==7)
cout<<" |";
else if(b[j]==0||b[j]==6||b[j]==8)
cout<<"|_|";
else
cout<<" _|";
}
}
cout<<endl;
}
}
return 0;
}