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

正文內(nèi)容

課程設(shè)計-赫夫曼編碼系統(tǒng)設(shè)計(編輯修改稿)

2025-02-09 18:45 本頁面
 

【文章內(nèi)容簡介】 value2 = list[j].weight。rnode = j。}}} 17 / 32 list[lnode].parent = i。list[rnode].parent = i。 list[i].weight = list[lnode].weight + list[rnode].weight。 list[i].lchild = lnode。list[i].rchild = rnode。}}void CreatHuffmanCode(HuffmanTree *list, HuffmanCode amp。code, int codeSize){int i, start。int flag1, flag2。 char *tempCode。if ((code = (char **)malloc(sizeof(char *) * codeSize)) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。exit(0)。}if ((tempCode = (char *)malloc(sizeof(char) * codeSize)) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。exit(0)。}tempCode[codeSize1] = 39。\039。for(i=0。 icodeSize。 ++i){start = codeSize 1。for(flag1=i, flag2=list[i].parent。 flag2 != 1。 flag1=flag2, flag2=list[flag2].parent){if (list[flag2].lchild == flag1){tempCode[start] = 39。039。}else{tempCode[start] = 39。139。 18 / 32}}if ((code[i] = (char *)malloc(sizeof(char) * (codeSize start))) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。exit(0)。}strcpy(code[i], amp。tempCode[start])。}free(tempCode)。}void DataCount(Static *amp。info){FILE *fp。char ch。char choice。int characterNumber, typeNumber。Data characterList。Data *ptr, *current, *previous。system(CLS)。printf(\n 請輸入需要打開的文件名稱: )。fflush(stdin)。gets(fileName)。while ((fp = fopen(fileName, rb)) == NULL){printf(\n 您需要打開的文件不存在, 是否需要重新打開(Y/N)? : )。fflush(stdin)。choice = getchar()。switch (choice){case 39。Y39。:system(CLS)。printf(\n 請輸入需要打開的文件名稱: )。fflush(stdin)。gets(fileName)。continue。 19 / 32case 39。N39。:return。default:break。}}characterNumber = typeNumber = 0。 = NULL。while ((ch = fgetc(fp)) != EOF){current = 。if (current == NULL){if ((ptr = (Data *)malloc(sizeof(Data))) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。exit(0)。}ptrdata = ch。ptrnumber = 1。ptrnext = 。 = ptr。++typeNumber。}else{while ((current != NULL) amp。amp。 (currentdata != ch)){previous = current。current = currentnext。}if (current != NULL){++(currentnumber)。++characterNumber。}else{ 20 / 32if ((ptr = (Data *)malloc(sizeof(Data))) == NULL){printf( 內(nèi)存不足, 操作失敗!\n)。exit(0)。}ptrdata = ch。ptrnumber = 1。ptrnext = current。previousnext = ptr。++typeNumber。++characterNumber。}}}fclose(fp)。codeSize = typeNumber。info = (Static *)malloc(sizeof(Static) * codeSize)。current = 。for (int i=0。 icodeSize。 ++i){info[i].data = currentdata。info[i].weight = (int)(currentnumber * / characterNumber)。current = currentnext。}}void FileEncoding(){char choice。while (true){system(CLS)。printf( 文件編碼程序\n)。Bound(39。39。, 25)。printf( 1. 創(chuàng) 建 文 件 編 碼 \n)。printf( 2. 導 出 文 件 編 碼 \n)。 21 / 32printf( 3. 導 出 文 件 密 鑰 \n)。printf( 0. 返 回 主 菜 單 \n)。Bound(39。39。, 25)。printf( 請選擇: )。fflush(stdin)。choice = getchar()。switch (choice){case 39。139。:CreatFileCoding()。break。case 39。239。:ExportFileEncoding(list, code, codeSize)。break。case 39。339。:ExportCharacterWeight()。break。case 39。039。:return。default:printf(\n 您的輸入有誤, 按任意鍵后請從新輸入!)。getch()。break。}}}void CreatFileCoding(){DataCount(info)。CreatHuffmanTree(list, info, codeSize)。CreatHuffmanCode(list, code, codeSize)。printf(\n 創(chuàng)建文件編碼成功! 按任意鍵繼續(xù)!)。getch()。}void ExportFileEncoding(HuffmanTree *list, HuffmanCode code, int codeSize){int i。char ch。char outFileName[30]。FILE *inFile, *outFile。 22 / 32system(CLS)。inFile = fopen(fileName, rb)。printf(\n 請創(chuàng)建導出文件名: )。fflush(stdin)。gets(outFileName)。if ((outFile = fopen(outFileName, wb)) == NULL){printf( 輸出文件創(chuàng)建失敗!\n)。exit(0)。}while ((ch = fgetc(inFile)) != EOF){for(i=0。 icodeSize。 ++i){if (list[i].data == ch){fputs(code[i], outFile)。break。}}}fcloseall()。printf(\n 導出文件成功! 按任意鍵繼續(xù)!)。getch()。}void ExportCharacterWeight(){char outFileName[30]。FILE *fp。system(CLS)。printf(\n 請創(chuàng)建導出文件名: )。fflush(stdin)。gets(outFileName)。 23 / 32if ((fp = fopen(outFileName, wb)) == NULL){printf( 輸出文件創(chuàng)建失敗!\n)。exit(0)。}for(int i=0。 icodeSize。 ++i){fprintf(fp, %c %d, info[i].data, info[i].weight)。}fclose(fp)。free(info)。free(list)。free(code)。printf(\n 導出文件成功! 按任意鍵繼續(xù)!)。getch()。}void FileDecoding(){char choice。while (true){system(CLS)。printf( 文件譯碼程序\n)。Bound(39。39。, 25)。printf( 1. 顯 示 文 件 內(nèi) 容 \n)。printf( 0. 返 回 主 菜 單 \n)。Bound(39。39。, 25)。printf( 請選擇: )。fflush(stdin)。choice = getchar()。switch (choice){case 39。139。:system(CLS)。DisplayContext()。break。 24 / 32case 39。039。:return。default:printf(\n 您的輸入有誤, 按任意鍵后請從新輸入!)。getch()。break。}}}void InportFileCoding(){FILE *fp。char choice。printf(\n 請輸入編碼文件名稱: )。fflush(stdin)。gets(fileName)。while ((fp = fopen(fileName, rb)) == NULL){printf(\n 將要導入的文件不存在, 是否需要重新導入(Y/N)? : )。fflush(stdin)。choice = getchar()。switch (choice){case 39。Y39。:system(CLS)。printf(\n 請輸入編碼文件名稱: )。fflush(stdin)。gets(fileName)。continue。case 39。N39。:return。default:break。}}fclose(fp)。printf(\n 文件導入成功! 下一步...\n)。} 25 / 32void InportCharact
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1