题目来源:

https://ac.2333.moe/Problem/view.xhtml?id=1219

  • [1219] Time

  • 时间限制: 1000 ms 内存限制: 131072 K
  • 问题描述
  • 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
  • 样例输出
  •     _  _  _ 
      | _||_ |_ 
      ||_  _||_|
     _  _     _ 
     _| _||_| _|
    |_  _|  ||_ 
  • 提示
  • The digits showed by the digital clock are as follows:
       _  _     _  _  _  _  _  _ 
     | _| _||_||_ |_   ||_||_|| |
     ||_  _|  | _||_|  ||_| _||_|
  • 来源
  • 辽宁省赛2010

思路:存一下字符,推一下位移;

参考代码:

#include <cstdio>
char s1[35]="     _  _     _  _  _  _  _  _ ";
char s2[35]="   | _| _||_||_ |_   ||_||_|| |";
char s3[35]="   ||_  _|  | _||_|  ||_| _||_|";
int main() {
    int a,b,c,d;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        getchar();//吸收换行
        if(a==0)a=10;
        if(b==0)b=10;
        if(c==0)c=10;
        if(d==0)d=10;
        printf("%c%c%c%c%c%c%c%c%c%c%c%c\n",s1[a*3-2],s1[a*3-1],s1[a*3],s1[b*3-2],s1[b*3-1],s1[b*3],s1[c*3-2],s1[c*3-1],s1[c*3],s1[d*3-2],s1[d*3-1],s1[d*3]);
        printf("%c%c%c%c%c%c%c%c%c%c%c%c\n",s2[a*3-2],s2[a*3-1],s2[a*3],s2[b*3-2],s2[b*3-1],s2[b*3],s2[c*3-2],s2[c*3-1],s2[c*3],s2[d*3-2],s2[d*3-1],s2[d*3]);
        printf("%c%c%c%c%c%c%c%c%c%c%c%c\n",s3[a*3-2],s3[a*3-1],s3[a*3],s3[b*3-2],s3[b*3-1],s3[b*3],s3[c*3-2],s3[c*3-1],s3[c*3],s3[d*3-2],s3[d*3-1],s3[d*3]);
    }
    return 0;
}