码迷,mamicode.com
首页 > 其他好文 > 详细

大数阶乘(高精度)

时间:2018-03-09 20:31:31      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:int   cpp   print   car   i++   turn   clu   pac   gpo   

#include <iostream>
using namespace std;


int main()
{
	int n, m, temp;
	//余数remainder 进位carry_bit 
	int remainder=0, carry_bit=0;
	cin>>m;
	int a[10000];
	for(int i=0; i<10000; i++) a[i]=0;
	a[1] = 1;
	for(int n=2; n<=m; n++)
	{
		remainder=0, carry_bit=0;
		for(int i=1; i<10000; i++)
		{
			temp = a[i]*n+carry_bit;
			remainder = temp%10;
			carry_bit = temp/10;
			a[i] = remainder;
		}
	}
	int i=9999;
	while(a[i]==0) i--;i++;
	while(--i!=0) printf("%d", a[i]);
	return 0;
} 

  

大数阶乘(高精度)

标签:int   cpp   print   car   i++   turn   clu   pac   gpo   

原文地址:https://www.cnblogs.com/kamicoder/p/8535503.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!