mymath.c

来自「用哈夫曼编码实现文件压缩和解压缩. 压缩过程的实现:1创建Haffman树&#」· C语言 代码 · 共 23 行

C
23
字号
#include "MyMath.h"
#include "MyAssert.h"
#include "Ulti.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
/*Attention when n is big ,this algorithm will have no little effect*/
long combination(int n,int m)/*output the group num from select from n element*/
{
	/*Algorithm Reason
	Cm,n=n!/(m!*(n-m)!)
	*/
	assertF(n>=m&&n<17,"in combination n<m or n is too big\n");
	if(n==m||m==0)return 1;
	else return jieCheng(n)/(jieCheng(m)*jieCheng(n-m));/**/
}

long jieCheng(int n)
{
	assertF(n>=0&&n<17,"in jieCheng n is<0 or n is too big!\n");
	if(n==1||n==0)return 1;
	else return n*jieCheng(n-1);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?