1. 程式人生 > >Problem: Time(一道水卻有意思的題

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; }