闲的有点蛋疼了又来做ACM,
效率有点低,
而且编译器也出了点问题。
具体就不分析了。
另:学学组成原理还是有必要的。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 36000
int num[MAX];
int product(int *data, int x, int len)
{
int c = 0;
int i;
for (i = 0; i <= len; i++)
{
data[i] *= x;
data[i] += c;
if (data[i] > 9)
{
c = data[i] / 10;
data[i] %= 10;
} else
{
c = 0;
}
}
while (data[i] != 0 || c != 0)
{
data[i] += c;
if (data[i] > 9)
{
c = data[i] / 10;
data[i] %= 10;
}
else
{
c = 0;
}
i++;
}
return i-1;
}
int main(void)
{
int n;
while ( (scanf("%d", &n) != EOF))
{
memset(num, 0, sizeof(num));
num[0] = 1;
int len = 0;
int i;
for (i = 2; i <= n; i++)
{
len = product(num, i, len);
}
for (i = len; i >= 0; i--)
printf("%d", num[i]);
printf("\n");
}
return 0;
}