📄 show.h
字号:
char showmenu(int i){
char c[7]={' ',' ',' ',' ',' ',' ',' '};
c[i]='<';
printf("----------------------------------------\n");
printf("| A.构造哈夫曼树%c |\n",c[1]);
printf("| B.对文件进行编码%c |\n",c[2]);
printf("| C.进行译码%c |\n",c[3]);
printf("| D.打印文件%c |\n",c[4]);
printf("| E.打印哈夫曼树%c |\n",c[5]);
printf("| F.退出%c |\n",c[6]);
printf("----------------------------------------\n");
return getch();
}
void printfile(){
char *a;
a=readfile(".\\code.txt");
msg(">开始打印文件");
printf("编码部分为:");
while(*a!='\0'){
if(*a=='|')
printf("\n字符串为:");
else
printf("%c",*a);
a++;
}
printf("\n");
msg(">打印文件完毕");
}
void Encoding(HuffmanTree HT,HuffmanCode HC,int n){
char s[100];
char out[1000];
char *temp;
int i=0,j;
msg("请输入要进行编码的字符串:");
scanf("%s",s);
out[0]='\0';
while(s[i]!='\0'){
for(j=1;j<=n;j++) {
if (s[i]==HT[j].code){
temp=HC[j];
strcat(out,temp);
}
}
i++;
}
writefile(out,".\\out.txt");
msg(">保存编码后文件完毕");
out[0]='\0';
for(i=1;i<=n;i++){
temp=HC[i];
strcat(out,temp); }
strcat(out,"|");
strcat(out,s);
writefile(out,".\\code.txt");
msg(">保存HC完毕");
}
void Uncoding(HuffmanTree HT,HuffmanCode HC,int n){
char *a;
int i=0,j=0,k,l=0;
char out[1000];
char temp[100];
out[0]='\0';
temp[0]='\0';
a=readfile(".\\out.txt");
while(*a!='\0'&&*a!=0xa){
temp[j]=*a;
j++;
for(k=1;k<=n;k++) {
if (strcmp(temp,HC[k])==0){
out[l]=HT[k].code;
l++;
while(j>=0){
temp[j]='\0';
j--;
}
j=0;
}
}
a++;
}
out[l]='\0';
msg(">译码完毕");
printf(">译码结果为:%s\n",out);
}
//void Uncoding(HuffmanTree HT,HuffmanCode HC,int n){
// char *a;
// int i=0,j=0,k,l=0;
// char out[1000];
// char temp[100];
// out[0]='\0';
// temp[0]='\0';
// a=readfile(".\\out.txt");
// while(*a!='\0'&&*a!=0xa){
// if (a[i]=='|'){
// for(k=1;k<=n;k++) {
// if (strcmp(temp,HC[k])==0){
// out[l]=HT[k].code;
// l++;
// }
// }
// while(j>=0){
// temp[j]='\0';
// j--;
// }
// j=0;
// }else{
// temp[j]=*a;
// j++;
// }
// a++;
// }
// out[l]='\0';
// msg(">译码完毕");
// printf(">译码结果为:%s\n",out);
//
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -