标签:blog os io ar 2014 cti div log
/******************************************************************** * @file Main_practise.cpp * @date 2014-8-14 * @author Tiger * @brief 练习 * @details 试编写一个计算斐波那契数列Fn的递归函数,并上机测试其 正确性。 ********************************************************************/ #include <iostream> #include <ctime> int CalFibonacciSequence(int n); int main(int argc, const char* argv[]) { srand(static_cast<unsigned int>(time(NULL))); int n = rand()%5; std::cout << "第" << n << "项为" << CalFibonacciSequence(n) << ".\n"; system("pause"); return 0; } int CalFibonacciSequence(int n) { if (0 == n || 1 == n) { return 1; } else { return CalFibonacciSequence(n-1) + CalFibonacciSequence(n-2); } }
标签:blog os io ar 2014 cti div log
原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/3913366.html