ACM 第一天水题 (2)

Problem: Clock

Problem Description

In order to get the run time of a user function,you can use the clock() function in time.h.Clock() use clock tick to measure time,which will increase CLK_TCK per second.Before a user function runs,you can call clock() and get the current tick C1,and after it finishes,call clock again and get another tick C2.Then the tot time the user function runs is (C2-C1)/CLK_TCK. In this problem,you can assume that CLK_TCK is 100.You should get the rum time from C1 and C2.


Input

Each line contains 2 integers C1 and C2(0<=C1


Output

Output the run time in the format of “hh:mm:ss”(hh is the hour,mm is the minute,ss is the second,each one should be two decimal places).Please note that less than one second of time should be rounded(四舍五入) to seconds.


Sample Input
123 4577973
0 49

Sample Output
12:42:59
00:00:00

思考:本题很简单
           四舍五入的方法,将总数 +0.5 之后进行相除便会得到四舍五入的结果
 
代码:
#include<stdio.h>
int main()
{
    long long c1,c2;
    while(scanf("%lld %lld",&c1,&c2)!=EOF)
    {
        int sum=(c2-c1+50)/100;
        int a = sum/3600;
        int b = (sum-(a*3600))/60;
        int c = sum %60;
        printf("%02d:%02d:%02d\n",a,b,c);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值