-
[1219] Time
- 时间限制: 1000 ms 内存限制: 131072 K
- 问题描述
-
Digital clock use 4 digits to express time, each digit is described by 3*3 characters (including”|”,”_”and” “).now given the current time, please tell us how can it be expressed by the digital clock.
- 输入
-
There are several test cases.
Each case contains 4 integers in a line, separated by space.
Proceed to the end of file. - 输出
-
For each test case, output the time expressed by the digital clock such as Sample Output.
- 样例输入
-
1 2 5 6 2 3 4 2
- 样例输出
-
_ _ _ | _||_ |_ ||_ _||_| _ _ _ _| _||_| _| |_ _| ||_
- 提示
-
The digits showed by the digital clock are as follows: _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_|
- 来源
-
辽宁省赛2010
- 操作
做法有很多,而且很精巧的办法也有的,下面列举几种办法,供大家学习
我的水办法
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
int i,j,k;
int a[4];
while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])!=EOF)
{
for(i=1;i<=3;i++)
{
if(i==1)
{
for(j=0;j<4;j++)
{
if((a[j]==2)||(a[j]==3)||(a[j]==5) ||(a[j]==6) ||(a[j]==7) ||(a[j]==8) ||(a[j]==9)|| (a[j]==0))
{
printf(" _ ");
}
else
printf(" ");
}
printf("\n");
}
if(i==2)
{
for(j=0;j<4;j++)
{
if((a[j]==1)||(a[j]==7))
{
printf(" |");
}
else
if((a[j]==2)||(a[j]==3))
printf(" _|");
else
if((a[j]==4)||(a[j]==8)||(a[j]==9))
{
printf("|_|");
}
else
if((a[j]==5)||(a[j]==6))
{
printf("|_ ");
}
else
printf("| |");
}
printf("\n");
}
if(i==3)
{
for(j=0;j<4;j++)
{
if((a[j]==1)||(a[j]==4)||(a[j]==7))
printf(" |");
else
if((a[j]==6)||(a[j]==8)||(a[j]==0))
printf("|_|");
else
if((a[j]==3)||(a[j]==5)||(a[j]==9))
printf(" _|");
else
if(a[j]==2)
{
printf("|_ ");
}
}
printf("\n");
}
}
// printf("\n");
}
return 0;
}
好办法
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
int p;
int a,b,c,d;
string time[10][100]=
{
{" _ "," "," _ "," _ "," "," _ "," _ "," _ "," _ "," _ "},
{"| |"," |"," _|"," _|","|_|","|_ ","|_ "," |","|_|","|_|"},
{"|_|"," |","|_ "," _|"," |"," _|","|_|"," |","|_|"," _|"}
};
while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
{
cout<<time[0][a]<<time[0][b]<<time[0][c]<<time[0][d]<<endl;
cout<<time[1][a]<<time[1][b]<<time[1][c]<<time[1][d]<<endl;
cout<<time[2][a]<<time[2][b]<<time[2][c]<<time[2][d]<<endl;
}
return 0;
}
// _ _ _ _ _ _ _ _
// | _| _||_||_ |_ ||_||_|| |
// ||_ _| | _||_| ||_| _||_|
#include<stdio.h>
#include<string.h>
int main()
{
int a[4],i,j,k;
char c[10][9];
strcpy(c[0]," _ | ||_|");
strcpy(c[1]," | |");
strcpy(c[2]," _ _||_ ");
strcpy(c[3]," _ _| _|");
strcpy(c[4]," |_| |");
strcpy(c[5]," _ |_ _|");
strcpy(c[6]," _ |_ |_|");
strcpy(c[7]," _ | |");
strcpy(c[8]," _ |_||_|");
strcpy(c[9]," _ |_| _|");
while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])!=EOF)
{
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
for(k=0;k<3;k++)
{
printf("%c",c[a[j]][i*3+k]);
}
}
putchar('\n');
}
}
return 0;
}