HNUSTOJ-1258 Time

1258: Time

时间限制: 1 Sec  内存限制: 128 MB
提交: 16  解决: 11
[提交][状态][讨论版]

题目描述

 

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

样例输出

    _  _  _ 
  | _||_ |_ 
  ||_  _||_|
 _  _     _ 
 _| _||_| _|
|_  _|  ||_ 

#include<iostream>
#include<cstring>
#include<cstdio>
 
using namespace std;
 
int main(){
    int a[4];
    while(scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) == 4){
        for(int i = 1; i <= 3; i++){
            for(int j = 0; j < 4 && i == 1; j++){
                if(a[j] == 1 || a[j] == 4) printf("   ");
                else printf(" _ ");
            }
            for(int j = 0; j < 4 && i == 2; j++){
                switch(a[j]){
                    case 4: case 8:
                    case 9: printf("|_|"); break;
                    case 1:
                    case 7: printf("  |"); break;
                    case 2:
                    case 3: printf(" _|"); break;
                    case 5:
                    case 6: printf("|_ "); break;
                    case 0: printf("| |"); break;
                }
            }
            for(int j = 0; j < 4 && i == 3; j++){
                switch(a[j]){
                    case 1: case 4:
                    case 7: printf("  |"); break;
                    case 2: printf("|_ "); break;
                    case 3: case 9:
                    case 5: printf(" _|"); break;
                    case 6: case 8:
                    case 0: printf("|_|"); break;
                }
            }
            printf("\n");
        }
    }
}

 

posted @ 2017-08-21 21:28  Pretty9  阅读(126)  评论(0编辑  收藏  举报