C语言编程题,写出程序,谢谢! 题目1大数阶乘 对给定的n(n≤100),计算并输出k!(k

2024-11-27 11:28:30
推荐回答(1个)
回答1:

#include "iostream"
using namespace std;
int a[1000001];
int main()
{
int n, j, i, t, b;
int len = 1;
cout<<"请输入一个数字:";
cin>>n;
a[1] = 1;
for (i = 2; i <= n; i++)
{
b = 0;
for (j = 1; j <= len; j++)
{
t = a[j] * i + b;
a[j] = t % 10;
b = t / 10;
if (j == len && b != 0)
len++;
}
}
for (i = len; i > 0; i--)
cout< cout<}