首页 > 其他 > 详细

Introduce 包含递归

时间:2014-12-04 17:38:12      阅读:215      评论:0      收藏:0      [点我收藏+]

个人学习笔记

 

递归是指函数调用自己本身。想知道什么是递归,首先你得知道什么是递归。
 
下面是一个显示当n为不同值时运行时间的小程序
#include<iostream> #include<ctime> using namespace std;

clock_t start = clock();  int f(long int num)
{ if(num == 0)
    {
        cout<<"Using "<<(clock())<<"seconds\n" ; return 0;
    }
    else f(num/2);
} int main()
{
    cout<<"The start time is: "<<start<<endl; long int n;
    cout<<"Please input a num:\n";
    cin>>n;
    f(n);
}


 

Introduce 包含递归

原文:http://www.cnblogs.com/kbe317/p/4143092.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!