When you feel the program is computing too slowly
you can use a “timer” to see exactly how slow it is
Specifically, it is a time.h header file
which lets you call the timing function clock()
Divide the obtained value by the constant CLOCK_PER_SEC
to get a value in seconds
How to write the code
First include the header file
| |
Then at the end of the program write
| |
But in this way you will find that the program time is too large
because the starting point of this timing is when the program is opened
so the time taken for keyboard input will also be included
so you can solve it with the command line
Open CMD (Command Prompt)
Enter
cd file directory
to change the current directory to the specified directory
For example:
Then enter echo input data | program name
For example:
abc is the filename of the program I created
You can get some data about input and output
so you can analyze it

There is still quite a difference from the data given in the book
It can be seen that my little computer’s computing ability is still okay~
Hahaha
Introduction to Algorithm Competition Classic — Liu Jiaru P26