当前位置: 代码迷 >> 综合 >> [PAT][Basic Level] 1026
  详细解决方案

[PAT][Basic Level] 1026

热度:40   发布时间:2023-12-05 22:57:09.0

AC CODE:
WARNING:omititng decimal fractions smaller than 0.5 and counting all others(四舍五入)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define CLK_TCK 100
int main()
{
    int c1,c2;cin>>c1>>c2;int hh,mm,ss;int ans = (c2 - c1);if(ans % CLK_TCK  < 50){
    ans /= CLK_TCK ;}else{
    ans /= CLK_TCK ;ans ++;}hh = ans/3600 ;ans= ans%3600;mm = ans/60 ;ss = ans%60 ;printf("%02d:%02d:%02d",hh,mm,ss);return 0 ;
}
  相关解决方案