展开全部
如果需要精确计算16和27的阶乘32313133353236313431303231363533e59b9ee7ad9431333361306332需要编写大整数计算,至少要实现大整数加法,大整数乘以短整数,大整数除以短整数,大整数转换为字符串用于显示结果。当然如果不需要精确计算可以使用浮点数来计算。#include
#include
#include
#include
typedef int BOOL;
typedef unsigned short LINT_B;
typedef unsigned long LINT_B2;
typedef LINT_B * LINT;
typedef const LINT_B * CLINT;
#define TRUE 1
#define FALSE 0
#define BASE 0x10000ul
#define BASEDIV2 0x8000ul
#define BASEMINONE 0xFFFFul
#define DIGITLEN 64 // 当 DIGITLEN = 64 时可以实现200以内的阶乘
#define Max(a, b) ((a)
#define Rmldzrs(l, h) do {while(*(--h) == 0); ++h; h = Max(l, h);} while(0);
const int sBitperdgt = sizeof(LINT_B) * 8;
// 复制大数
LINT copy(CLINT f, CLINT l, LINT x)
{
while(f != l) *x++ = *f++;
return x;
}
// 大数是否为0
inline BOOL isZero(CLINT l, CLINT h)
{
Rmldzrs(l, h);
return (l == h) ? TRUE : FALSE;
}
// 调换字符串的顺序
void reverse(char *s)
{
char t;
char *sl = s;
char *sh = sl + strlen(s);
while(sl
}
// 交换大数指针
void s