2018湘潭校赛 A-时间统计

xiaoxiao2021-02-28  22

时间统计

题目描述

某个实验需要统计时间,记录了实验开始和结束的时间,计算实验用了多少秒。

输入

第一行输入一个整数n,表示样例个数。接下来每组样例两行,表示开始时间和结束时间,格式为xdayHH:MM:SS,x是一个整数表示第几天,0 < x < 20000,HH表示小时,MM表示分钟,SS表示秒,保证时间合法,结束时间比开始时间晚。

输出

每组数据输出一行一个整数,表示经过的秒数。

样例

输入 2 1day03:26:12 1day04:26:12 123day15:00:01 19999day15:00:00 输出 3600 1717286399

题意

签到题。。。

AC代码

#include <bits/stdc++.h> using namespace std; #define LL long long #define CLR(a,b) memset(a,(b),sizeof(a)) const int MAXN = 1e3+10; int main() { // ios::sync_with_stdio(false); LL T; cin >> T; while(T--) { LL x, h, m, s; LL x1, h1, m1, s1; // string ss; // cin >> x >> ss >> h >> ss >> m >> ss >> s; // cin >> x1 >> ss >> h1 >> ss >> m1 >> ss >> s1; scanf("%lldday%lld:%lld:%lld%lldday%lld:%lld:%lld",&x,&h,&m,&s,&x1,&h1,&m1,&s1); LL sum = x*24*60*60+h*60*60+m*60+s; LL sum1 = x1*24*60*60+h1*60*60+m1*60+s1; cout << sum1-sum << endl; } return 0; }
转载请注明原文地址: https://www.6miu.com/read-2629418.html

最新回复(0)