zoukankan      html  css  js  c++  java
  • 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("
    ");
            }
        }
    }
  • 相关阅读:
    相对布局(下)
    html5-微格式-时间的格式
    html5-新元素新布局模板
    html5-section元素
    html5-article元素
    html5-新布局元素header,footer
    html5-基本知识小结及补充
    html5-常用的通用元素
    html5-div布局
    html5-块元素和内联元素
  • 原文地址:https://www.cnblogs.com/Pretty9/p/7406781.html
Copyright © 2011-2022 走看看