POJ 2840 Big Clock

举报
谙忆 发表于 2021/05/27 01:23:43 2021/05/27
【摘要】 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 ...

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

水题,如果分钟不为0,就输出0就ok;
01:00和1:00是一样的;

#include <stdio.h>
#include <stdlib.h>
int main()
{ int t; int a,b; scanf("%d",&t); while(t--){ scanf("%d:%d",&a,&b); if(b!=0){ printf("0\n"); continue; } if(a>=0&&a<=12){ printf("%d\n",(a+12)%25); } if(a>12){ printf("%d\n",(a+12)%24); } } return 0;
}

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

文章来源: chenhx.blog.csdn.net,作者:谙忆,版权归原作者所有,如需转载,请联系作者。

原文链接:chenhx.blog.csdn.net/article/details/49884859

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。