-
大小: 2KB文件類型: .c金幣: 1下載: 0 次發(fā)布日期: 2021-06-03
- 語(yǔ)言: C/C++
- 標(biāo)簽:
資源簡(jiǎn)介
費(fèi)諾編碼C語(yǔ)言實(shí)現(xiàn),實(shí)現(xiàn)文件的讀入與寫(xiě)出,可修改任意數(shù)字,實(shí)現(xiàn)任意個(gè)數(shù)的編碼。
代碼片段和文件信息
/**
?*
?*?Fano?Code
?*
?*?@author?Xu?jian
?*?
?*?2010.11.27
?*/
#include
#include
#include
#define?N?8
struct?event?{
int?n;
double?x;
int?code[N];
int?low;
};
FILE?*fp1*fp2;
struct?event?A[N+1];
void?inputcode(struct?event?*aint?b)/*input?code*/
{
a->code[a->low]=b;
(a->low)++;
}
void?outcode(struct?event?a)/*output?code*/
{
int?i;
for(i=0;i fprintf(fp2“%d“a.code[i]);
}
double?getsum(int?hint?tstruct?event?a[])/*get?sum*/
{
int?i=h;
double?sum=0.0;
for(i=h;i<=t;i++)
{
sum=sum+a[i].x;
}
return?sum;
}
int?getbreakpoint(struct?event?a[]int?hint?t)/*all?right*/
{
int?nt1;
double?f[N+1]temp=0.0;
for(n=h;n {
f[n]=fabs(getsum(hna)-getsum(n+1ta));
}
temp=f[h];
t1=h;
for(n=h;n {
if(f[n] {
temp=f[n];
t1=n;
}
}
return?t1;
}
void?group(int?hint?tstruct?event?a[])
{
int?ibreakpointzero=0one=1;
if(t==h+1)
{
inputcode(&a[h]zero);
inputcode(&a[t]one);
- 上一篇:華中科技大學(xué)C++實(shí)驗(yàn)
- 下一篇:重言式判別
評(píng)論
共有 條評(píng)論