基本思想:
老生常谈的问题,这种阶乘主要考察溢出。
用大数、long long、double可以解决;
关键点:
无;
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
double fun(double n) {
if (n == 1)
return 1;
double cnt = 1;
while (n != 0.0) {
cnt *= n;
n--;
}
return cnt;
}
int main() {
double n;
while (cin >> n) {
printf("%.0lf\n", fun(n));
}
return 0;
}
来源:https://www.cnblogs.com/songlinxuan/p/12446293.html