当前位置:网站首页>B1026 program running time
B1026 program running time
2022-07-27 05:20:00 【Ye Chen】
1026 Program running time (15 branch )
To get one C The running time of language program , A common method is to call the header file time.h, It provides clock() function , You can capture from the beginning of the program to clock() The time taken to be called . This time unit is clock tick, namely “ Clock strike ”. And there's also a constant CLK_TCK, The number of clock ticks per second of the machine clock is given . So in order to get a function f Running time of , We just call f Call before clock(), Get a clock beat C1; stay f Call... After the execution is completed clock(), Get another clock beat C2; The difference between the number of clock ticks obtained twice (C2-C1) Namely f The number of clock ticks consumed by the operation , Then divide by the constant CLK_TCK, You get the running time in seconds .
Let's simply assume that the constant CLK_TCK by 100. Now, given the number of clock beats obtained before and after the measured function , Please give the running time of the tested function .
Input format :
The input is given in order on one line 2 It's an integer C1 and C2. Note that the clock points obtained twice must be different , namely C1 < C2, And the value is in [0,10 Of 7 Power ].
Output format :
Output the running time of the function under test in one line . The running time must be in accordance with hh:mm:ss( namely 2 Bit when : branch : second ) Format output ; Insufficient 1 The time of seconds is rounded to seconds .
sample input
123 4577973
sample output
12:42:59
Topic analysis :
- There's nothing to say
The code is as follows :
#include<bits/stdc++.h>
#define CLK_TCK 100
using namespace std;
int main(){
int a,b;
cin>>a>>b;
double z=1.0*(b-a)/CLK_TCK;
int number=round(z);
printf("%02d:%02d:%02d\n",number/3600,(number/60)%60,number%60);
return 0;
}
边栏推荐
- 实用小工具: Kotlin 代码片段
- The difference between strlen and sizeof
- Acticiti中startProcessInstanceByKey方法在variable表中的如何存储
- 35.滚动 scroll
- What should test / development programmers over 35 do? Many objective factors
- How to store the startprocessinstancebykey method in acticiti in the variable table
- How idea creates a groovy project (explain in detail with pictures and texts)
- 传智教育|软件测试工程师未来的发展方向有哪些?
- B1031 查验身份证
- JDBC API 详解
猜你喜欢

稀疏数组→五子棋的存盘续盘等操作

MQ message queue is used to design the high concurrency of the order placing process, the generation scenarios and solutions of message squeeze, message loss and message repetition

1、 MySQL Foundation

Integrate SSM

File dialog box

TypeScript 详解

JVM上篇:内存与垃圾回收篇十一--执行引擎

Differences among left join, inner join and right join

34. 分析flexible.js

Critical path principle
随机推荐
How idea creates a groovy project (explain in detail with pictures and texts)
学生管理系统
Detailed description of binary search tree
JVM Part 1: memory and garbage collection part 11 -- execution engine
35.滚动 scroll
Derivation and explanation of PBR physical illumination calculation formula
数据库设计——关系数据理论(超详细)
Dialog data transfer
Installation and template setting of integrated development environment pychar
Event Summary - common summary
B1023 group minimum
Domestic mainstream ERP software market
Create datasource using Druid connection pool
LocalDateTime和ZonedDateTime
Jmeter 界面如何汉化?
A math problem cost the chip giant $500million
Typescript details
Use of collection framework
LeetCode之6 ZigZag Conversion
Test basis 5