题解 | #n的阶乘#
n的阶乘
https://www.nowcoder.com/practice/97be22ee50b14cccad2787998ca628c8
#include <iostream> #include <cstdio> using namespace std; long Function(int x){ if(x==1){ return x; } else{ return x* Function(x-1); } } int main() { long n; while (scanf("%ld",&n)!=EOF){ printf("%ld",Function(n)); } return 0; }
题目的数据范围更大,用long型,替代符事ld
考研复试机试 文章被收录于专栏
考研复试机试