看你要不要完整的数了。
随便写了个
# include <stdio.h>
# define MaxLen 1000000ul
char Result [MaxLen] = { 1 };
long Bit;
void Factorial ( long num ) {
long temp, i;
while ( num >= 2 ) {
for ( temp = 0 , i = 0 ; i <= Bit ; i++ ) {
temp = *( Result + i ) * num + temp;
*( Result + i ) = temp % 100;
temp /= 100;
}
for ( ; temp > 0 ; temp /= 100 ) *( Result + ( ++Bit ) ) = temp % 100;
num--;
}
}
void Print ( ) {
for ( printf ( "%ld" , *( Result + Bit ) ) ; --Bit >= 0 ; )
printf ( "%02ld" , *( Result + Bit ) );
}
int main ( ) {
long num;
scanf ( "%ld" , &num );
Factorial ( num );
Print ( );
system ( "pause" );
return 0;
}
随便写了个
# include <stdio.h>
# define MaxLen 1000000ul
char Result [MaxLen] = { 1 };
long Bit;
void Factorial ( long num ) {
long temp, i;
while ( num >= 2 ) {
for ( temp = 0 , i = 0 ; i <= Bit ; i++ ) {
temp = *( Result + i ) * num + temp;
*( Result + i ) = temp % 100;
temp /= 100;
}
for ( ; temp > 0 ; temp /= 100 ) *( Result + ( ++Bit ) ) = temp % 100;
num--;
}
}
void Print ( ) {
for ( printf ( "%ld" , *( Result + Bit ) ) ; --Bit >= 0 ; )
printf ( "%02ld" , *( Result + Bit ) );
}
int main ( ) {
long num;
scanf ( "%ld" , &num );
Factorial ( num );
Print ( );
system ( "pause" );
return 0;
}
当对C的经验增加时,它会显的很好用.----Dennis M Ritche如是说