C - Time

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:
   _  _     _  _  _  _  _  _ 
 | _| _||_||_ |_   ||_||_|| |
 ||_  _|  | _||_|  ||_| _||_|

忘记了怎么给字符数组赋值,比赛完又看了看,发现以前学的东西真的记不住啊!还是要认真做笔记!

赋值:

char name[4][8] = {{"Canada "},{"Canada "},{"Canada "},{"Canada "} };

或者

char c[5][50]= {

" _ _ _ _ _ _ _ _ ",

"| | | _| _||_||_ |_ ||_||_|",

"|_| ||_ _| | _||_| ||_| _|",

};

这样一行一行赋值,外围需要大括号,内部每组用引号括起来,逗号隔开。

不可以先定义后后赋值

除非借助strcpy(a,“safa”);

其他的没什么说的,注意格式就行了。

#include<stdio.h>
#include<string.h>
char c[5][50]=
{
    " _     _  _     _  _  _  _  _ ",
    "| |  | _| _||_||_ |_   ||_||_|",
    "|_|  ||_  _|  | _||_|  ||_| _|",
};
int main()
{
    int k[5];
   while(~scanf("%d %d %d %d",&k[0],&k[1],&k[2],&k[3]))
    for(int h=0; h<3; h++)
    {
        for(int i=0; i<4; i++)
        {
            for(int j=k[i]*3; j<k[i]*3+3; j++)
            {
                printf("%c",c[h][j]);
            }
        }
        printf("\n");
    }
}

 

上一篇:CF1311D Three Integers - 数学


下一篇:取模运算的应用