hufapp.cpp
来自「这是C++数值算法(第二版)的源代码,其中包含了目前一些比较常用的数值计算的算法」· C++ 代码 · 共 18 行
CPP
18 行
#include "nr.h"
void NR::hufapp(Vec_IO_ULNG &index, Vec_I_ULNG &nprob, const unsigned long n,
const unsigned long m)
{
unsigned long i=m,j,k;
k=index[i];
while (i < (n >> 1)) {
if ((j = 2*i+1) < n-1
&& nprob[index[j]] > nprob[index[j+1]]) j++;
if (nprob[k] <= nprob[index[j]]) break;
index[i]=index[j];
i=j;
}
index[i]=k;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?