Problem: Clock
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.
Each line contains 2 integers C1 and C2(0<=C1
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.
0 49
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;
}