C语言计算递归程序的运行时间

来源:百度知道 编辑:UC知道 时间:2024/05/21 11:18:08
如何在C语言中计算递归算法的运行时间?

在开始的时候,输出一个系统时间,结束的时候输出一个系统时间.
#include<time.h>
..............
..............
void main(){
struct tm sttime,fitime;
_getsystime(&sttime);
m=1;
a[0]=0;
a[1]=1;
while(m>0){
if(check(m)){
if(m==L-1){
out();
change();
}else
extend();
}else
change();
}
_getsystime(&fitime);
printf("starttime: %d:%d\n",sttime.tm_min,sttime.tm_sec);
printf("finishtime:%d:%d\n",fitime.tm_min,fitime.tm_sec);
}