ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:15.96KB ,
资源ID:14963125      下载积分:5 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-14963125.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(实验三LZW编码.docx)为本站会员(b****5)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

实验三LZW编码.docx

1、实验三LZW编码实验三 LZW编码一、实验目的1、加深对LZW编码的理解;2、掌握LZW编码的程序设计。二、原理与说明LZW编码的步骤:串表a1aab7b2bc8c3cb9aa4baa10ab5aaba11ba6abb12a a b aa b c ba aab ab bc1 1 2 4 2 3 6 7 5 8三、实验内容利用C、VB或VC语言实现LZW编码的算法,掌握LZW编码的程序设计并调试通过。四、实验设备计算机程序如下:#include#include#include#include#include#define BIRS 12#define HASHING_SHIFT BITS-8#d

2、efine MAX_VALUE(1BITS)-1#define MAX_CODE MAX_VALUE-1#if BITS=14#define TABLE_SIZE 18041#endif#if BITS=13#define TABLE_SIZE 9029#endif#if BITS=12#define TABLE_SIZE 5021int *code_value;unsigned int *prefix_code;unsigned char *append_character;unsigned char decode_stack4000;char ok;find match(int hash_

3、perfix,unsigned int hash_character) int index; int offset; index=(hash_characterHASHING_SHIFT)hash_prefix; if(index=0) offset=1; else offset=TABLE_SIZE-index; while(1) if(code_valueindex=-1) return(index); if(prefix_codeindex=hash_prefix&append_characterindex=hash_character) return(index); index-=of

4、fset; if(index0) index+=TABLE_SIZE; input_code(FILE*input) unsigned int return_value; static int input_bit_count=0; static unsigned long input_bit_buffer=0L; while(input_bit_count=24) input_bit_buffer|=(unsigned long)getc(input)(32-BITS); input_bit_buffer=BITS; input_bit_count-=BITS; return(return_v

5、alue);void output_code(FILE*output,unsigned int code) static int output_bit_count=0; static unsigned long output_bit_buffer=0L; output_bit_buffer|=(unsigned long)code=8) putc(output_bit_buffer24,output); output_bit_buffer=8; output_bit_count-=8; void compress(FILE *input,FILE *output) unsigned int n

6、ext_code; unsigned int character; unsigned int string_code; unsigned int index; int i; next_code=256; for(i=0;iTABLE_SIZE;i+) code_valuei=-1; i=0; printf(nnCompressing.n); string_code=getc(input); while(character=getc(input)!=(unsigned)EOF) index=find_match(string_code,character); if(code_valueindex

7、!=-1) string_code=code_valueindex; else if(next_code=next_code) *decode_stack=character; string=(unsigned char*)decode_string(decode_stcak+1,old_code); else string=(unsigned char*)decode_string(decode_stck,nex_code); character=*string; while(string=decode_stack) putc(*string-,output); if(next_code25

8、5) *buffer+=append_charactercode; code=prefix_codecode; if(i+=4094) printf(Fatal error during code expansion.n); exit(0); *buffer=code; return(char*)buffer); int main(int argc,char*argv) FILE*input_file; FILE*output_file; FILE*lzw_file; char input_file_name81; int select; character=*string; while(st

9、ring=decode_stack) putc(*string-,output); if(next_code1) strcpy(input_file_name,argv1); else printf(nInput file name?); scanf(%s,input_file_name); printf(nCompressed file name?); scanf(%s,compressed_file_name); input_file=fopen(input_file_name,rb); lzw_file=fopen(compressed_filename,wb); while(input

10、_file=NULL|lzw_file=NULL) printf(Fatal error opening files!n); printf(nInput file names?); scanf(%s,input_file_name); printf(nCompressed file name?); scanf(%s,compressed_file_name); input_file=fopen(input_file_name,rb); lzw_file=fopen(compressed_filename,wb); ; compress(input_file,lzw_file); fclose(

11、input_file); fclode(lzw_file); free(code_value); else if(select=2) printf(nOnput file names?); scanf(%s,onput_filename); printf(nExpanded file name?); scanf(%s,expanded_filename); input_file=fopen(onput_filename,rb); lzw_file=fopen(expanded_filename,wb); while(lzw_file=NULL|output_file=NULL) printf(

12、Fatal error opening files!n); printf(nOnput file names?); scanf(%s,onput_filename); printf(nExpanded file name?); scanf(%s,expanded_filename); input_file=fopen(onput_filename,rb); lzw_file=fopen(expanded_filename,wb); ; expand(lzw_file,output_file); fclose(lzw_file); fclose(output_file); else exit(0); printf(nContinue or not(y/n)?); scanf(%c,&ok); getchar(); if(ok=y) goto loop; else printf(Complete.nnPress any key to continue); getchar(); free(prefix_code); free(append_character); return 0;

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2