#include <the iostream>
the using namespace STD;
#define 1000 N
int BigNumFactorial (the Num int [], int n-);
void the Print (the Num int [], int Index, n-int);
int main (void)
{
int n-;
int Num [N] = {1, 0}; // the first number is initialized to 1, and the rest are initialized to 0
cout << "what you need to calculate the factorial of a number?" << endl;
cin the n->> ;
int BigNumFactorial Index = (the Num, n-);
the Print (the Num, Index, n-);
return 0;
}
int BigNumFactorial (the Num int [], int n-) // Large Numbers factorial
{
int I, J, = SUM. 1, TEMP;
int Index = 0; // array for indicating the number of valid position
for (I = 2; I <= n-; I ++)
{
TEMP = 0;
for (J = 0; J <= Index; J ++)
{
Sum = I * the Num [J] + TEMP;
IF (! Sum / 10 = 0) // Number Description sum more than one
{
the Num [J] sum = 10%;
TEMP = sum / 10; // called ' carry '
}
the else
{
the Num [J] = SUM;
TEMP = 0;
}
}
IF (TEMP = 0!) // If' carry 'not to 0
{
Index = J -. 1;
the while (TEMP)
{
Index ++;
the Num [Index] = 10% TEMP;
TEMP / = 10;
}
}
}
return Index;
}
void Print(int Num[], int Index, int n)
{
int i;
cout << n << "阶的结果为: ";
for(i = Index; i >= 0; i--)
{
cout << Num[i];
}
cout << endl;
}
Tarsus factorial (c ++ to achieve)
Guess you like
Origin www.cnblogs.com/ReturnOfTheKing/p/11228042.html
Recommended
Ranking