当前位置:网站首页>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;
}
边栏推荐
- Quoted popular explanation
- 文件处理(IO)
- JVM Part 1: memory and garbage collection part 12 -- stringtable
- Basic operation of vim
- What is the future development direction of software testing engineers?
- QT menu bar, toolbar and status bar
- Scientific Computing Library -- Matplotlib
- 34. Analyze flexible.js
- ssm框架整合
- JVM上篇:内存与垃圾回收篇十一--执行引擎
猜你喜欢

JVM上篇:内存与垃圾回收篇二--类加载子系统

Explore the mysteries of the security, intelligence and performance of the universal altek platform!

Li Kou achieved the second largest result

Raspberry pie RTMP streaming local camera image

Database connection pool & Druid usage

2、 MySQL advanced

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

idea远程调试debug

How to sinicize the JMeter interface?

ssm框架整合
随机推荐
Card drawing program simulation
Test basis 5
实用小工具: Kotlin 代码片段
Two dimensional array summation exercise
JVM上篇:内存与垃圾回收篇十--运行时数据区-直接内存
Detailed explanation of pointer constant and constant pointer
Demo of throttling function -- regular expression matching
The provision of operation and maintenance manager is significantly affected, and, for example, it is like an eep command
Counting Nodes in a Binary Search Tree
1、 MySQL Foundation
一、MySQL基础
Critical path principle
Interface and abstract class / method learning demo
How to sinicize the JMeter interface?
B1025 reverse linked list*******
Integrate SSM
2、 MySQL advanced
LeetCode之6 ZigZag Conversion
Install pyGame
The interface can automatically generate E and other asynchronous access or restart,