int Factorial( const int N );
其中N是用户传入的参数,其值不超过12。如果N是非负整数,则该函数必须返回N的阶乘,否则返回0。
int Factorial( const int N )
{
int temp = 0,i;
if(N >= 0)
{
temp = 1;
if(N == 1|| N == 0)
{
return temp;
}else {
i = N;
while(i > 1)
{
temp = temp * i;
i--;
}
return temp;
}
}else
return 0;
}