题目描述:
源码:
#include"iostream" using namespace std; int main() { int n, digit, carry, tmp; int a[40000]; while(cin>>n) { if(n <= 1) { cout<<1<<endl; } else { a[0] = 1; digit = 1; for(int i = 2; i <= n; i++) { carry = 0; for(int j = 0; j < digit; j++) { tmp = a[j] * i + carry; a[j] = tmp % 10; carry = tmp / 10; } while(carry > 0) { a[digit] = carry % 10; digit++; carry /= 10; } } for(int j = digit - 1; j >= 0; j--) { cout<<a[j]; } cout<<endl; } } return 0; }