大数阶乘(高精度)

#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;
} 

  

posted @ 2018-03-09 19:06  kami_coder  阅读(239)  评论(0编辑  收藏  举报