求10000以内n的阶乘

xiaoxiao2021-02-28  33

#include<bits/stdc++.h> using namespace std; int a[40010],n,x,len=1; int main() {     cin>>n;     a[1]=1;     for(int i=1;i<=n ;i++)     {     x=0;     for(int j=1;j<=len;j++)     {         a[j]=a[j]*i+x;         x=a[j]/10;         a[j]%=10;         if(x>0&&j>=len)len++;     }     }     for(int i=len;i>=1;i--)     cout<<a[i];     return 0; }
转载请注明原文地址: https://www.6miu.com/read-2627924.html

最新回复(0)