Problem: Time(一道水却有意思的题

Problem Description

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.

Input

There are several test cases.

Each case contains 4 integers in a line, separated by space.

Proceed to the end of file.

Output

For each test case, output the time expressed by the digital clock such as Sample Output.

Sample Input
1 2 5 6
2 3 4 2
Sample Output
    _  _  _
  | _||_ |_
  ||_  _||_|
_  _     _
_| _||_| _|
|_  _|  ||_

这道题很明显就是判断输入并输出,虽然简单,不过分类的时候的确令人头痛

代码:
#include <stdio.h>
int main()
{
    int c[5];
    while(scanf("%d",&c[1])!=EOF)
    {
       for(int i=2;i<=4;i++)
       scanf("%d",&c[i]);
       
       for(int i=1;i<=4;i++)
       if(c[i]==2||c[i]==3||c[i]==5||c[i]==6||c[i]==7||c[i]==8||c[i]==9||c[i]==0)
       printf(" _ ");
       else if(c[i]==1||c[i]==4)
       printf("   ");
       printf("\n");
       
       for(int i=1;i<=4;i++)
       if(c[i]==1||c[i]==7)
       printf("  |");
       else if(c[i]==2||c[i]==3)
       printf(" _|");
       else if(c[i]==4||c[i]==8||c[i]==9)
       printf("|_|");
       else if(c[i]==5||c[i]==6)
       printf("|_ ");
       else if(c[i]==0)
       printf("| |");
       printf("\n");
       
       for(int i=1;i<=4;i++)
       if(c[i]==1||c[i]==4||c[i]==7)
       printf("  |");
       else if(c[i]==2)
       printf("|_ ");
       else if(c[i]==3||c[i]==5||c[i]==9)
       printf(" _|");
       else if(c[i]==6||c[i]==8||c[i]==0)
       printf("|_|");
       printf("\n");
    }
    
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/packy/p/9905547.html
今日推荐