#include <stdio.h>
int func(int n){
if(n < 0){
printf("你输入的结果有误; 请重新输入");
}else if(n == 0 || n == 1){
return 1;
}
return func(n - 1) * n;
}
int main(int argc, const char * argv[]) {
int num;
printf("请输入一个数:\n");
scanf("%d",&num);
printf("%d",func(num));
return 0;
}
|
|