You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include <stdio.h>
|
|
int N(int n)
|
|
{
|
|
if(n<=1)
|
|
return 1;
|
|
else
|
|
return N(n-1)*n;//关键思想
|
|
}
|
|
int main()
|
|
{
|
|
int n=0;
|
|
int ret=0;
|
|
printf("请输入你想要求阶乘的数:");
|
|
scanf("%d",&n);
|
|
ret=N(n);
|
|
printf("%d的阶乘是%d\n",n,ret);
|
|
return 0;
|
|
|
|
}
|