-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tree #6
Comments
以下是汪铮沁同学的霍夫曼树代码,解码部分会报错,谁来帮她解决一下? #include |
首先需要 #include<vector>
#include<queue>
#include<iostream> 下面这段代码循环上限写错了导致z丢了,一错到底 for (int n = 0; n < 27; n++)
{
a[n] = new Node;
a[n]->data = f[n];
for (int i = 0; i < 10; i++) a[n]->code[i] = ' ';
if (a[n]->data != 0) a[n]->str = array0[n];
else a[n]->str = '!';
a[n]->num = '-1';
a[n]->left = a[n]->right = a[n]->father = NULL;
if (f[n] != 0) cout << array0[n] << "-" << f[n] << endl;
}
for (int n = 27; n < 100; n++)
{
a[n] = new Node;
a[n]->data = 0;
for (int i = 0; i < 10; i++) a[n]->code[i] = ' ';
a[n]->str = '!';
a[n]->num = '-1';
a[n]->left = a[n]->right = a[n]->father = NULL;
} 而且最后还没释放 char array2[] = {01110}; 不加引号真的令人窒息…… 加上引号应该有可能输出正确结果了 |
http://wangmengds.ml/tree/
The text was updated successfully, but these errors were encountered: