练习3

// 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)
{
int sum =1;
for (int i=1;i<=n;i++)
{
sum *=i;
}
return sum;
}

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

 

你可能感兴趣的:(练习3)