/*
Once wa n times, the error occurs at ① and must be supplemented at ②.
*/
# Include <cstdio>
# Include <cstring>
Const int nmax= 50000;
Struct BigNumber
{
Int data [nMax];
Int len;
BigNumber () {len = 1; memset (data, 0, sizeof (data ));}
BigNumber & operator = (const char * str );
BigNumber operator * (int a); // here, the multiplier only needs to be an integer.
Void print ();
Void clearLeadZero ();
} Ans;
Void BigNumber: clearLeadZero ()
{
While (len> 1 &&! Data [len-1]) len --;
}
BigNumber & BigNumber: operator = (const char * str)
{
Memset (data, 0, sizeof (data); // ②
Len = strlen (str );
Int I;
For (I = 0; I <len; ++ I)
Data [I] = str [len-I-1]-'0 ';
Return * this;
}
BigNumber: operator * (int)
{
Int q = 0;
BigNumber z;
Int I;
For (I = 0; I <len; ++ I)
// ① This is a positive solution, but for (I = 0; I <len; ++ I) then removes the while () loop and returns an error! The answer is at ②.
{
Int p = data [I] * a + q;
Z. data [I] = p % 10;
Q = p/10;
}
While (q)
{
Z. data [I ++] = q % 10;
Q/= 10;
}
Z. len = I;
Z. clearLeadZero ();
Return z;
}
Void BigNumber: print ()
{
Int I;
For (I = len-1; I> = 0; -- I)
Printf ("% d", data [I]);
Printf ("\ n ");
}
Int N;
Int main ()
{
// Freopen ("f: // data. in", "r", stdin );
// Freopen ("f: // data2.out", "w", stdout );
While (scanf ("% d", & N )! = EOF)
{
Ans = "1 ";
Int I;
For (I = 2; I <= N; ++ I)
Ans = ans * I;
Ans. print ();
}
Return 0;
}
From lhshaoren