练习4

// Factorial.cpp : Defines the entry point for the console application.
/*

data:2013/10/05

auth:ljz

func:

n!的递归实现

*/

#include "stdafx.h"
#include "iostream"
using namespace std;
int Factorial(int n)
{
if (n==1)
{
return 1;
}
else
{
return n*Factorial(n-1);
}
}

int main(int argc, char* argv[])
{
int a =0;
cin>>a;
cout<<Factorial(a)<<endl;
return 0;
}

 

posted @ 2013-10-05 20:35  呱呱老师  阅读(120)  评论(0编辑  收藏  举报