nefu 677 Gift


Time

Time Limit 1000ms

Memory Limit 65536K

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

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

hint

  The digits showed by the digital clock are as follows:
     _  _     _  _  _  _  _  _ 
   | _| _||_||_ |_   ||_||_|| |
   ||_  _|  | _||_|  ||_| _||_|
								
							
想當年的時候,這道題用了一個半小時做出來了,用的switch-case語句,現在用同樣的方法我用了半個小時搞定,說明我進步了嗎~O(∩_∩)O~

還有別的方法請多指教

代碼:

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;

 int main()
  {
     int n,i,j,k,a[5];
  while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]))
    { for(i=0;i<4;i++)
     {
    switch(a[i])
      { case 2:
        case 3:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 0:printf(" _ ");break;
        case 4:
        case 1:printf("   ");break;}}
   printf("\n");
    for(i=0;i<4;i++)
     {
       switch(a[i])
      { case 2:
        case 3:printf(" _|");break;
        case 5:
        case 6:printf("|_ ");break;
        case 7:printf("  |");break;
        case 4:
        case 8:
        case 9:printf("|_|");break;
        case 0:printf("| |");break;
        case 1:printf("  |");break;}}
    printf("\n");
     for(i=0;i<4;i++)
     {
      switch(a[i])
      { case 2:printf("|_ ");break;
        case 9:
        case 3:
        case 5:printf(" _|");break;
        case 8:
        case 6:printf("|_|");break;
        case 7:printf("  |");break;
        case 0:printf("|_|");break;
        case 4:
        case 1:printf("  |");break;}
     }
   printf("\n");



      }




    return 0;
  }




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章