问题描述:
C语言问题:请帮我解释一下这个代码的思路
Description
输入不超过 1000 的正整数 n ,输出 = 1 X 2 X 3 … X n 的精确结果.
Input
多组测试数据,对于每组测试数据输入一个正整数 n.
Output
对于每组测试数据输出一行,表示 的结果.
Sample Input
30
Sample Output
265252859812191058636308480000000
#include
#include
const int maxn = 3003;
int f[maxn];
int main(){
\x09int i,j,n;
\x09while (scanf("%d",&n)!=EOF){
\x09\x09memset( f,0,sizeof(f) );
\x09\x09f[0] = 1;
\x09\x09for (i = 2; i = 0; --j) if ( f[j] ) break;
\x09\x09for (i = j; i >= 0; --i) printf("%d",f[i]);
\x09\x09puts("");
\x09}
\x09return 0;
}
Description
输入不超过 1000 的正整数 n ,输出 = 1 X 2 X 3 … X n 的精确结果.
Input
多组测试数据,对于每组测试数据输入一个正整数 n.
Output
对于每组测试数据输出一行,表示 的结果.
Sample Input
30
Sample Output
265252859812191058636308480000000
#include
#include
const int maxn = 3003;
int f[maxn];
int main(){
\x09int i,j,n;
\x09while (scanf("%d",&n)!=EOF){
\x09\x09memset( f,0,sizeof(f) );
\x09\x09f[0] = 1;
\x09\x09for (i = 2; i = 0; --j) if ( f[j] ) break;
\x09\x09for (i = j; i >= 0; --i) printf("%d",f[i]);
\x09\x09puts("");
\x09}
\x09return 0;
}
问题解答:
我来补答展开全文阅读