• 1027:电子钟


    题目描述

    电子钟用四个数字来表示时间,每个数字的尺寸为3*3,用于表示数字的字符包括‘|’、‘_’和空格。

    现在给你当前的时间,请你告诉我们电子钟是如何展示这个时间的。

    电子钟显示的数字样式如下:

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

    输入格式

    输入包含多组测试数据。每组输入包含4个整数,表示当前时间。

    输出

    对于每组输入,输出由电子钟显示出来的时间样式。

    样例输入

    1 2 5 6
    2 3 4 2

    样例输出

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

    题目不难,只是怎么输出是个问题,下面附上自己的代码

     1 #include <stdio.h> 
     2 typedef struct
     3 {
     4     char *str1;
     5     char *str2;
     6     char *str3;
     7 }elva;
     8 int main(void)
     9 {
    10     elva str[10];
    11     str[1].str1="   ";
    12     str[1].str2="  |";
    13     str[1].str3="  |";
    14     str[2].str1=" _ ";
    15     str[2].str2=" _|";
    16     str[2].str3="|_ ";
    17     str[3].str1=" _ ";
    18     str[3].str2=" _|";
    19     str[3].str3=" _|";
    20     str[4].str1="   ";
    21     str[4].str2="|_|";
    22     str[4].str3="  |";
    23     str[5].str1=" _ ";
    24     str[5].str2="|_ ";
    25     str[5].str3=" _|";
    26     str[6].str1=" _ ";
    27     str[6].str2="|_ ";
    28     str[6].str3="|_|";
    29     str[7].str1=" _ ";
    30     str[7].str2="  |";
    31     str[7].str3="  |";
    32     str[8].str1=" _ ";
    33     str[8].str2="|_|";
    34     str[8].str3="|_|";
    35     str[9].str1=" _ ";
    36     str[9].str2="|_|";
    37     str[9].str3=" _|";
    38     str[0].str1=" _ ";
    39     str[0].str2="| |";
    40     str[0].str3="|_|";
    41     int a,b,c,d;
    42     
    43     while((scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF))
    44     {
    45         int i;
    46         printf("%s%s%s%s
    ",str[a].str1,str[b].str1,str[c].str1,str[d].str1);
    47         printf("%s%s%s%s
    ",str[a].str2,str[b].str2,str[c].str2,str[d].str2);
    48         printf("%s%s%s%s
    ",str[a].str3,str[b].str3,str[c].str3,str[d].str3);
    49     }
    50     return 0;
    51     
    52 }
  • 相关阅读:
    ncnn 编译配置
    Android 配置 ncnn
    Android Studio 配置 OpenCV4+
    ROS catkin cheat sheet
    CMake 使用代理服务器
    Git设置代理服务器
    安卓assets处理
    【Android】Toast on non-UI thread
    高级语言编译和运行系统
    linux环境安装包方式
  • 原文地址:https://www.cnblogs.com/sairre/p/3952345.html
Copyright © 2020-2023  润新知