• Big Clock


    Problem Description
    Our vicar raised money to have the church clock repaired for several weeks. The big clock, which used to strike the hours days and nights, was damaged several weeks ago and had been silent since then.

    After the clock was repaired, it works all right, but there is still something wrong with it: the clock will strike thirteen times at one o’clock, fourteen times at two o’clock... 24 times at 12:00, 1 time at 13:00...

    How many times will it strike now?
     
    Input
    The first line consists of only one integer T (T <= 30), representing the number of test cases. Then T cases follow.

    Each test case consists of only one line, representing the time now. Each line includes 2 integers H, M separated by a symbol ":". (0 <= H < 24, 0 <= M < 60)
     
    Output
    For each test case, output the answer in one line.
     
    Sample Input
    3 1:00 01:01 00:00
     
    Sample Output
    13 0 12
    这是一个水题,题意是输出几点,然后输出敲了几下,注意表是坏的,例如12点的时候是输出24。下面附上我过了的代码,希望对大家有帮助。

    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {int t,a,b;
    scanf("%d",&t);
    while(t--)
    {
    scanf("%2d:%2d",&a,&b);
    if(b!=0)
    printf("0 ");
    if(b==0)
    {
    if(a<=12)
    printf("%d ",a+12);
    if(a>12)
    printf("%d ",a-12);
    }

    }

    return 0;
    }

  • 相关阅读:
    JAVA---File递归遍历文件目录,输出绝对路径
    JAVA--Map集合
    (笔记)JAVA--集合实现斗地主洗牌、发牌、看牌(利用TreeSet排序)
    SVN简单使用
    System.Object
    动态创建控件
    select 查询
    数据类型
    入门(值得注意的地方)
    错误调式 异常处理
  • 原文地址:https://www.cnblogs.com/1314wamm/p/4989379.html
Copyright © 2020-2023  润新知