FZU 1857 Clock in the mirror(模拟)

97 篇文章 0 订阅


Yr is on the English class,she is so sleepy that she want to know how long the class will last.So,she try to find out the current time.But the only clock is on the back wall of the classroom,and frequent turning might offend the teacher. 
Clever as she is, Yr take out a mirror.Now,she can see the clock in the mirror.Unfortunately,the time in the mirror maybe not the real time.Now,it’s time for you to do her a favor.She will give you the time in the mirror and ask you to tell her the real time.
Input
Multiple cases. 
Each case shows in one line as the format: hh:mm 
All legal time is show in 12 hours system.
Output
One line for each case.Please output the real time in 12 hours system according to the time given in the format hh:mm.If the time YR tell you is illegal,please out put ”That is a joke.”.
Sample Input
9:00
12:00
Sample Output
03:00
That is a joke.

题解:

有点意思的一题,给你一个时间,求镜面钟的时间(正过来反过来都可以),要注意有坑点,就是当m不为0的时候h--

代码:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
#define lson k*2
#define rson k*2+1
#define M (t[k].l+t[k].r)/2
#define ll long long
#define INF 10086111
int main()
{
	int h,m;
	while(scanf("%d:%d",&h,&m)!=EOF)
    {
        if(h<0||h>=12||m<0||m>=60)
        {
            printf("That is a joke.\n");
            continue;
        }
        m=60-m;
        if(m==60)
            m=0;
        h=12-h;
        if(m!=0)
            h--;
        if(h==12)
            h=0;
        printf("%02d:%02d\n",h,m);
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值