题解 | #n的阶乘#
n的阶乘
https://www.nowcoder.com/practice/97be22ee50b14cccad2787998ca628c8
#include<cstdio> #include<iostream> using namespace std; int main() { int n; cin>>n; long long chengji=1; int i; for(i=1;i<=n;i++) { chengji=chengji*i; } cout<<chengji; }
主要是20!过大,注意结果的类型:long long