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