加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 大数据 > 正文

大数阶乘(10000)

发布时间:2021-01-20 17:53:18 所属栏目:大数据 来源:网络整理
导读:大数阶乘 #includestdio.h#includestring.h#includemath.h#includealgorithmusing namespace std;const int maxn=40000;int a[maxn];int BigJC(int n){? ? int i,j;? ? memset(a,sizeof(a));? ? a[0]=1;? ? for(i=2; i=n; i++)? ? {? ? ? ? int c=0;? ? ?

大数阶乘

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
const int maxn=40000;


int a[maxn];
int BigJC(int n)
{
? ? int i,j;
? ? memset(a,sizeof(a));
? ? a[0]=1;
? ? for(i=2; i<=n; i++)
? ? {
? ? ? ? int c=0;
? ? ? ? for(j=0; j<maxn; j++)
? ? ? ? {
? ? ? ? ? ? int s=a[j]*i+c;
? ? ? ? ? ? a[j]=s%10;
? ? ? ? ? ? c=s/10;
? ? ? ? }
? ? }
}

int main()
{
? ? int n;
? ? int i,j;
? ? while(~scanf("%d",&n))
? ? {
? ? ? ? BigJC(n);
? ? ? ? for(j=maxn-1; j>=0; j--)//去除“前”导零;
? ? ? ? ? ? if(a[j])
? ? ? ? ? ? ? ? break;
? ? ? ? for(i=j; i>=0; i--)
? ? ? ? ? ? printf("%d",a[i]);
? ? ? ? printf("n");
? ? }
? ? return 0;
}

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读