91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.01MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-11-08
  • 語言: C/C++
  • 標簽: LZW??無損壓縮??

資源簡介

本程序實現了LZW的無損文本壓縮,使用C語言實現,整個文件為VC的工程。

資源截圖

代碼片段和文件信息

#pragma?warning(disable:4786)
//...
#include??
#include??
//...
#include?
#include?“BitToByte.h“

using?namespace?std;
using?namespace?BitToByte;

void?init_table();
void?decode();
void?init_decode_dictionary();


map?dictionary;
map?decode_dictionary;?
//int?Buff[4000];

int?num?=?0;

int?main()
{
init_table();

char?ch;

FILE?*fp;

int*?bits?=?new?int;

if((fp=fopen(“I?have?a?dream.txt““r“))==NULL)?
{
printf(“not?open“);
return?1;
}

int?code?=?0;

// map?m;
// m.insert(pair(1“st“));
// dictionary.insert(pair(“student_three“?code));

unsigned?char?*?r?=?new?unsigned?char[4];

string?str;
string?c;

ch?=?fgetc(fp);
str?=?ch;

unsigned?char?*?cr?=?new?unsigned?char[4];?

while?(true)?
{
ch=fgetc(fp);

c?=?ch;
if?(dictionary.find(str?+?c)?!=?dictionary.end())
{
str?+=?c;
}
else
{
// cout?<second?<
int?res?=?(dictionary.find(str))->second;
// cout?< intToCharPoint(res?12?cr);
addToBuff(cr?12);

// printBuff();
// cout?< num++;

dictionary.insert(map::value_type(str?+?c?dictionary.size()));
str?=?c;

if?(ch?==?EOF)
break;
}

// putchar(ch);
}
// printBuff();


// cout?< saveAsFile(“LZW.txt“);

cout?<
decode();


/*
FILE?*fp2;

if((fp2=fopen(“LZW.txt““r“))==NULL)?
printf(“not?open“);



int?k?=?0;
while?(k? {
k++;

ch=fgetc(fp2);
cout?< }*/


return?0;
}

void?decode()
{
FILE?*fp;

if((fp=fopen(“LZW.txt““r“))==NULL)?
printf(“not?open“);

init_decode_dictionary();

string?str?=?““;

string?entry;


unsigned?char*?cp?=?new?unsigned?char[3];
int?sizeOfByte?=?0;
int?res?=?0;

int?num?=?0;

bool?odd?=?true;
while?(num?<=?BitToByte::size_of_file)?/*?從文件讀一字符,顯示到屏幕*/
{

if?(odd)
{
odd?=?false;
// sizeOfByte?=?fread(cp?1?3?fp);
*cp=buff[num];
num++;
*(cp+1)=buff[num];
num++;
*(cp+2)=buff[num];
num++;
// if?((*cp?==?EOF)||(*(cp+1)?==?EOF)||(*(cp+2)?==?EOF))
// break;
// if?(sizeOfByte?!=?3?)
// break;

res?=?(*cp)?*?16?+?((*(cp+1))?>>?4);
}
else
{
res?=?((*(cp?+?1))?&?0x0f)?*?256?+?*(cp+2);
odd?=?true;
}
// ch?=?Buff[i];
if?(decode_dictionary.find(res)?!=?decode_dictionary.end())
entry??=?(decode_dictionary.find(res))->second;
else
entry?=?str?+?str[0];
cout?<
// cout?<
if?(str?!=?““)
{
decode_dictionary.insert(map::value_type(decode_dictionary.size()?str?+?entry[0]));
}
str=?entry;
i++;
// entry?=?dictionary
}

// cout?<
// cout?<
cout?<}


void?init_table()
{

char?c

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????4501??2011-10-25?10:53??LZW\BitToByte.h

?????文件?????589861??2011-10-25?10:53??LZW\Debug\LZW.exe

?????文件?????865968??2011-10-25?10:53??LZW\Debug\LZW.ilk

?????文件????2575200??2011-10-24?16:58??LZW\Debug\LZW.pch

?????文件????1238016??2011-10-25?10:53??LZW\Debug\LZW.pdb

?????文件?????377096??2011-10-25?10:53??LZW\Debug\main.obj

?????文件??????99328??2011-10-25?10:53??LZW\Debug\vc60.idb

?????文件?????159744??2011-10-25?10:53??LZW\Debug\vc60.pdb

?????文件???????9134??2011-10-23?11:38??LZW\I?have?a?dream.txt

?????文件???????4313??2011-10-24?17:47??LZW\LZW.dsp

?????文件????????529??2011-10-24?16:30??LZW\LZW.dsw

?????文件??????50176??2011-10-25?10:53??LZW\LZW.ncb

?????文件??????50688??2011-10-25?10:53??LZW\LZW.opt

?????文件???????1242??2011-10-25?10:53??LZW\LZW.plg

?????文件???????4885??2011-10-25?10:53??LZW\LZW.txt

?????文件???????5370??2011-10-25?10:52??LZW\main.cpp

?????文件??????????9??2011-10-24?17:43??LZW\res

?????文件???????3256??2011-10-24?21:50??LZW\res.txt

?????文件?????????14??2011-10-24?17:20??LZW\test?-?副本.txt

?????文件?????????15??2011-10-24?21:08??LZW\test.txt

?????目錄??????????0??2011-10-25?10:53??LZW\Debug

?????目錄??????????0??2011-10-25?10:53??LZW

-----------?---------??----------?-----??----

??????????????6039345????????????????????22


評論

共有 條評論