2020牛客暑期多校训练营(第二场)D

Duration

https://ac.nowcoder.com/acm/contest/5667/D

题目描述

Given two moments on the same day in the form of HH:MM:SS, print the number of seconds between the two moments.

输入描述

Input two lines each contains a string in the form of , denoting a given moment.

输出描述

Only one line containing one integer, denoting the answer.

示例1

输入

12:00:00
17:00:00

输出

18000

示例2

输入

23:59:59
00:00:00

输出

86399

分析

  以每天的 作为基准,分别算出两个时刻距离基准的时间间隔 ,两个时间间隔差的绝对值即为答案。

代码

/******************************************************************
Copyright: 11D_Beyonder All Rights Reserved
Author: 11D_Beyonder
Problem ID: 2020牛客暑期多校训练营(第二场) Problem D
Date: 8/11/2020
Description: Easy Calculation
*******************************************************************/
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
    int HH,MM,SS;
    scanf("%d:%d:%d",&HH,&MM,&SS);
    int a=HH*3600+MM*60+SS;
    scanf("%d:%d:%d",&HH,&MM,&SS);
    int b=HH*3600+MM*60+SS;
    cout<<abs(a-b)<<endl;
    return 0;
}
牛客暑期多校训练营题解 文章被收录于专栏

收集牛客暑期多校训练营的题解

全部评论

相关推荐

07-02 13:52
武汉大学 golang
骗你的不露头也秒
牛客87776816...:😃查看图片
点赞 评论 收藏
分享
牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
白火同学:大二有这水平很牛了,可以适当对关键信息加粗一点,比如关键技术、性能指标之类的。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务