freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

課程設(shè)計-赫夫曼編碼系統(tǒng)設(shè)計-wenkub

2023-01-28 18:45:54 本頁面
 

【正文】 次此的程序只能進(jìn)行簡單的加密與解密操作。end = 0。++end。exit(0)。char *tempCode。InportFileCoding()。}}return false。}}. 字符解碼//此代碼用于比較查找赫夫曼編碼bool CompareData(char *tempCode, int amp。 icodeSize。codeSize = typeNumber。previousnext = ptr。exit(0)。current = currentnext。++typeNumber。} 8 / 32ptrdata = ch。 = NULL。N39。fflush(stdin)。switch (choice){case 39。gets(fileName)。 7 / 32Data *ptr, *current, *previous。char ch。//存放字符個數(shù)struct node *next。tempCode[start])。139。 flag2 != 1。/**************************從葉子結(jié)點到根結(jié)點逆向求編碼***********************/for(i=0。}if ((tempCode = (char *)malloc(sizeof(char) * codeSize)) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。int flag1, flag2。 list[i].lchild = lnode。rnode = j。rnode = lnode。 lnode = rnode = 1。ptrparent = ptrlchild = ptrrchild = 1。 ilimit。 ++i, ++ptr){ptrdata = info[i].data。 //limit 為赫夫曼樹結(jié)點個數(shù)if ((list = (HuffmanTree *)malloc(sizeof(HuffmanTree) * limit)) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。 int lnode, rnode。 //存放字符數(shù)據(jù)int weight。 //存放字符數(shù)據(jù) int weight。5. 詳細(xì)設(shè)計程序主體結(jié)構(gòu)分為文件編碼與文件解碼兩個子程序。最后,因為每個文件中的內(nèi)容不同,所以每個文件的赫夫曼編碼也不同,而赫夫曼編 3 / 32碼是根據(jù)字符的權(quán)重生成的,所以每個文件都對應(yīng)一個字符權(quán)重系列(即密鑰) ,如果失去這個密鑰,即使對文件進(jìn)行了加密,也不同解密文件的內(nèi)容,即文件加密失效,所以在生成加密文件后,一定要導(dǎo)出文件的字符權(quán)重(即密鑰) ,以待之后的解碼使用。然后根據(jù)得到的字符權(quán)重,構(gòu)造赫夫曼樹并因此完成赫夫曼編碼(至此,文件的導(dǎo)入分析過程已完成) 。特別是,不同的文本文件有不同的字符處理形式,所以因此每一個文本都會有一個相應(yīng)的密鑰,用于對文本的解碼?!稊?shù)據(jù)結(jié)構(gòu)》課程設(shè)計報告課程名稱 :赫夫曼編碼系統(tǒng)姓 名 : 學(xué) 號 : 專 業(yè) : 班 級 : 指導(dǎo)教師 : 二〇一二年 十二月 1 / 32目錄 Contents1. 課程小組 2. 小組成員及分工 22. 設(shè)計目的和要求 23. 需求分析 24. 設(shè)計說明 2. 文件編碼(加密) 2. 文件解碼(解密) 35. 詳細(xì)設(shè)計 3. 程序主體結(jié)構(gòu) 3. 主要算法說明 3. Huffman 樹 3. Huffman 編碼 5. 字符權(quán)重計算 6. 字符解碼 96. 實驗結(jié)果 10. 實驗結(jié)果說明 10. 程序運行截圖 117. 設(shè)計體會 128. 參考文獻(xiàn) 139. 附:程序代碼 13 2 / 321. 課程小組…2. 設(shè)計目的和要求通過課程設(shè)計,讓學(xué)生進(jìn)一步熟悉與鞏固數(shù)據(jù)結(jié)構(gòu)中常用算法,加深體會利用數(shù)據(jù)結(jié)構(gòu)的算法解決實際問題的能力,培養(yǎng)學(xué)生進(jìn)行復(fù)雜程序設(shè)計的技能,提高學(xué)生的思維能力、并促進(jìn)其綜合應(yīng)用能力、分析能力和團(tuán)隊合作能力的提高。4. 設(shè)計說明本次編寫的程序按著對文件的編碼(加密)和解碼(解密)的兩大步驟展開。然后讓操作人員選擇對文件進(jìn)行編碼。 (至此,文件的加密工作應(yīng)經(jīng)全部完成) 。文件編碼后分別導(dǎo)出編碼后文件與文件密鑰。 //存放字符權(quán)重int parent, lchild, rchild。 //存放字符權(quán)重}Static。 int value1, value2。exit(0)。ptrweight = info[i].weight。 ++i, ++ptr){ptrdata = 39。}/***********************開始建立赫夫曼樹 ******************************/ for(i=codeSize。//此部分函數(shù)功能為選擇權(quán)值最小的兩個結(jié)點 for(j=0。 value1 = list[j].weight。}}}//此部分函數(shù)功能為選擇出的結(jié)點建立關(guān)系 list[lnode].parent = i。list[i].rchild = rnode。 char *tempCode。exit(0)。 icodeSize。 flag1=flag2, flag2=list[flag2].parent){if (list[flag2].lchild == flag1){tempCode[start] = 39。}}if ((code[i] = (char *)malloc(sizeof(char) * (codeSize start))) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。}free(tempCode)。}Data。char choice。system(CLS)。while ((fp = fopen(fileName, rb)) == NULL){printf(\n 您需要打開的文件不存在, 是否需要重新打開(Y/N)? : )。Y39。gets(fileName)。:return。//從文件中讀取信息并統(tǒng)計while ((ch = fgetc(fp)) != EOF){current = 。ptrnumber = 1。}else{while ((current != NULL) amp。}if (current != NULL){++(currentnumber)。}ptrdata = ch。++typeNumber。info = (Static *)malloc(sizeof(Static) * codeSize)。 ++i){info[i].data = currentdata。position){for (position = 0。}void DisplayContext(){InportCharacterWeight()。FILE *fp。char ch。}end = 0。tempCode[end] = 39。}}printf(\n\n 按任意鍵結(jié)束!)。 11 / 32(圖 1:赫夫曼加密程序主體窗口)(圖 2:赫夫曼文件編碼程序窗口)(圖 3:用于測試的文本 原始文本內(nèi)內(nèi)容)(圖 4:導(dǎo)出文件編碼后,在創(chuàng)建的編碼文件中生成的二進(jìn)制數(shù)) 12 / 32(圖 5:導(dǎo)出的文本密鑰(即字符權(quán)重) )(圖 6:赫夫曼文件譯碼程序窗口)(圖 7:將之前生成的編碼文件與密鑰導(dǎo)入進(jìn)來后顯示出原來的文本內(nèi)容)7. 設(shè)計體會進(jìn)過此次的實驗,讓我對樹結(jié)構(gòu)及最優(yōu)二叉樹概念與操作的理解。8. 參考文獻(xiàn)[1]嚴(yán)蔚敏、[2]Thomas 、Charles .9. 附:程序代碼includeincludeincludeinclude//赫夫曼樹結(jié)構(gòu)typedef struct{ char data。 //字符權(quán)重結(jié)構(gòu)typedef struct{char data。int number。 14 / 32//創(chuàng)建赫夫曼樹void CreatHuffmanTree(HuffmanTree *amp。//從文件中讀取數(shù)據(jù)并計算各字符出現(xiàn)頻率void DataCount(Static *amp。//導(dǎo)出編碼后文件void ExportFileEncoding(HuffmanTree *list, HuffmanCode code, int codeSize)。//導(dǎo)入文件中字符權(quán)重void InportCharacterWeight()。void Bound(char character, int size)。//字符種數(shù)int codeSize。printf( 赫夫曼編碼加密程序\n)。printf( 1. 文 件 編 碼 \n)。39。choice = getchar()。break。break。system(PAUSE)。getch()。 int lnode, rnode。if ((list = (HuffmanTree *)malloc(sizeof(HuffmanTree) * limit)) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。 ++i, ++ptr){ptrdata = info[i].data。 ilimit。ptrparent = ptrlchild = ptrrchild = 1。 lnode = rnode = 1。rnode = lnode。rnode = j。 list[i].lchild = lnode。int flag1, flag2。}if ((tempCode = (char *)malloc(sizeof(char) * codeSize)) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。for(i=0。 flag2 != 1。139。tempCode[start])。char ch。Data *ptr, *current, *previous。gets(fileName)。switch (choice){case 39。fflush(stdin)。N39。 = NULL。}ptrdata = ch。++typeNumber。current = currentnext。exit(0)。previousnext = ptr。codeSize = typeNumber。 icodeSize。}}void FileEncoding(){char choice。39。 21 / 32printf( 3. 導(dǎo) 出 文 件 密 鑰 \n)。, 25)。switch (choice){case 39。case 39。case 39。case 39。getch()。CreatHuffmanCode(list, code, codeSize)。char ch。inFile = fo
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1