View code
# Include <iostream>
Using Namespace STD;
# Define Maxcompute 100
# Define Base 10000
Void Multiply ( Int A [], Int Max, Int B) // The multiplication of large numbers. Pay attention to parameter transmission.
{
Int I, array = 0 ;
For (I = max- 1 ; I> = 0 ; I --)
{
Array + = B * A [I];
A [I] = array % base; // Each digit in the array contains four digits with a large number.
Array/= base;
}
}
Void Divide ( Int A [], Int Max, Int B) // Simulate division of large numbers
{
Int I, DIV = 0 ;
For (I = 0 ; I <Max; I ++)
{
DIV = div * base + A [I];
A [I] = div/B;
Div % = B;
}
}
Int Main ()
{
Int A [ 101 ] [Max], I, N;
Memset ([ 1 ], 0 , Max *Sizeof ( Int ));
For (I = 2 , [ 1 ] [Max- 1 ] = 1 ; I < 101 ; I ++) // High coordinate storage of large numbers low
{
Memcpy (A [I], a [I- 1 ], Max *Sizeof ( Int )); // H [I] = H [I-1];
Multiply (A [I], Max, 4 * I- 2 ); // H [I] * = (4 * I-2 );
Divide (A [I], Max, I + 1 ); // H [I]/= (I + 1 );
}
While (CIN> N & N)
{
For (I = 0 ; I <Max & a [n] [I] = 0 ; I ++ ); // Remove the number 0 before the array.
Cout <a [n] [I ++]; // Output the first non-zero number
For (; I <Max; I ++)
{
Printf ( " % 04d " , A [n] [I]); // Output The number next to it, and each person must be 4 characters in length! (32767)
}
Cout <Endl;
}
Return 0 ;
}