计算机里的时间程序要怎么编?

来源:百度知道 编辑:UC知道 时间:2024/05/17 16:54:51
急啊,拜托各位高手帮帮忙吧

#include <time.h>
clock_t start, stop; /* clock_t is a built-in type for processor time (ticks) */
double duration; /* records the run time (seconds) of a function */

int main ( )
{ … …
/* clock() returns the amount of processor time (ticks) that has elapsed
since the program began running */
start = clock(); /* records the ticks at the beginning of the function call */
function(); /* run your function here */
stop = clock(); /* records the ticks at the end of the function call */
duration = ((double)(stop - start))/CLK_TCK;
/* CLK_TCK is a built-in constant = ticks per second */
… …
return 1;
}