#include<iostream>
using namespace std;
int Fact(int n)
{
if (n == 1)
{
return 1;
}
else
{
return n * Fact(n - 1);
}
}
int main()
{
int n;
cout << "请输入n:";
cin >> n;
cout << Fact(n);
return 0;
}
为什么100的阶乘输出为0
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
micthis 2023-10-25 17:26关注100!=93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000,太大了,int类型装不下只装了后面的0了,结果溢出了。
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报 编辑记录解决 1无用