资源简介
统计编码的算术编码,用代码来实现,输入任意字串 ,输出其算术编码

代码片段和文件信息
#include
#define M 100
#define N 4
class suanshu
{
int countlength;
char number[N]n;
long double chance[N]c;
char code[M];
long double HighLowhighlowd;
public:
suanshu()
{High=0;Low=0;}
void get_number();
void get_code();
void coding();
~suanshu(){}
};
void suanshu::get_number()
{
cout<<“please input the number and its chance.“< for(int i=0;i {
cin>>n>>c;
number[i]=n;
chance[i]=c;
}
if(i==20)
cout<<“the number is full.“< count=i;
}
void suanshu::get_code()
{
cout<<“please input the code‘‘s length:“;
cin>>length;
while(length>=M)
{
cout<<“the length is too largerplease input a smaller one.“;
cin>>length;
}
for(int i=0;i {
cin>>code[i];
}
}
void suanshu::coding()
{
int ij=0;
for(i=0;i if(code[0]==number[i]) break;
while(j Low+=chance[j++];
d=chance[j];
High=Low+d;
for(i=1;i for(j=0;j {
if(code[i]==number[j])
{
if(j==0)
{
low=Low;
high=Low+chance[j]*d;
High=high;
d*=chance[j];
}
else
{
float chance_l=0.0;
for(int k=0;k<=j-1;k++)
chance_l+=chance[k];
low=Low+d*chance_l;
high=Low+d*(chance_l+chance[j]);
Low=low;
High=high;
d*=chance[j];
}
}
else continue;
}
cout<<“the result is:“< }
int main()
{
suanshu a;
a.get_number();
a.get_code();
a.coding();
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1496 2009-06-02 21:20 1\1.cpp
文件 3341 2009-06-02 21:20 1\1.dsp
文件 41984 2009-06-02 21:23 1\Debug\vc60.idb
文件 61440 2009-06-02 21:20 1\Debug\vc60.pdb
文件 244272 2009-06-02 21:20 1\Debug\1.pch
文件 11124 2009-06-02 21:23 1\Debug\1.obj
文件 263028 2009-06-02 21:23 1\Debug\1.ilk
文件 233547 2009-06-02 21:23 1\Debug\1.exe
文件 435200 2009-06-02 21:20 1\Debug\1.pdb
文件 33792 2009-06-02 21:24 1\1.ncb
文件 723 2009-06-02 21:23 1\1.plg
文件 48640 2009-06-02 21:24 1\1.opt
文件 510 2009-06-02 21:24 1\1.dsw
目录 0 2009-06-02 21:20 1\Debug
目录 0 2009-06-02 21:01 1
----------- --------- ---------- ----- ----
1379097 15
- 上一篇:很好用的断网工具
- 下一篇:PSCAD中MMC建模
相关资源
- 触摸屏TPC7063E与S7 300 PLC之间MPI通信实
- KUKA 编程案例讲解.ppt
- Scratch 吃豆人追踪者.sb3
- labview编程软件滤波器以及编写程序设
- Scratch 变脸(将人物图片变成各种各样
- UNIX/LINUX编程实践教程的源码
- Windows异步套接字网络编程
- 编程实现二维DCT变换
- MT4编程 EA模板
- 音乐代码转换软件 单片机编程时用
- PLC上位机编程软件
- 一种红外遥控编解码仿真
- 用Socket编程实现FTP
- S7-200模拟量编程实例
- 防火墙编程-Visual C 网络通信开发
- 数据采集系统——ADC0808的应用,单片
- MFC网络编程实例
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- ADC0809数字电压表 LCD1602显示 汇编程序
- 108种编程中常见的问题及解决办法
- Siemens PLC编程精品例程11.机械手GRAPH
- SOCKET 网络编程 计算机网络 作业 客户
- PC汇编编程钢琴程序
- 浙大ACM编程竞赛的摸板
- 武汉大学测绘学院大地测量学编程-
- 武汉大学测绘学院大地测量学编程-
- 操作系统实验综合设计【附代码】
- 汇编编程实现二进制和十六进制之间
- VC 编程实现活动主机扫描源代码
评论
共有 条评论