<span style="font-family: Arial, Helvetica, sans-serif;">#include <stdlib.h></span>
#include <stdio.h>
#include <string.h>
#include "oj.h"
void CalcNN(int n, char *pOut)
{
if(0 == n || 1 == n)
{
pOut[0] = 1;
pOut[1] = '\0';
}
else
{
int product[1000] ;
memset(product, 0, sizeof(int) * 1000);
int temp = 0; //存储临时变量
int carry = 0; //进位标志
int len = 1; //数组长度
product[0] = 1;
for ( int i = 2; i <= n; ++i)
{
carry = 0;
for (int j = 0; j < len; ++ j)
{
temp = product[j] * i + carry;
product[j] = temp % 10;
carry = temp /10;
}
while(carry != 0)
{
product[len] = carry % 10;
carry /= 10;
len ++;
}
}
for (int i = 0; i < len; ++i)//逆序存储
{
pOut[i] = product[len - i -1] + '0';
}
pOut[len] = '\0';
}
return;
}