求解这个代码哪里出问题了吗?编译不通过,非常感谢
#include<stdio.h>
#include<string.h>
#define n 5
#define m 2*n-1
typedef struct{
int weight;
int parent;
int lchild;
int rchild;
}HTNode;
typedef struct{
char ch;
char code[n];
}nodecode;
void InitHuffmanTree( HTNode ht[m])
{
int i=0;
for(i=1;i<=m;i++)
{
ht[i].weight=0;
ht[i].lchild=0;
ht[i].rchild=0;
ht[i].parent=0;
}
}
void Inputweight(HTNode ht[m])
{
int i=0;
for(i=1;i<=n;i++)
{
printf("请输入第%d个权值:",i);
scanf("%d",&ht[i].weight);
}
}
void selectmin(HTNode ht[m],int s1,int s2,int i)
{
int minweight=100;
for(i=1;i<=m;i++)
{
if((ht[i].weight<minweight)&&(ht[i].parent==0))
{
minweight=ht[i].weight;
}
}
s1=i;
minweight=100;
for(i=1;i<=m;i++)
{
if((ht[i].weight<minweight)&&(ht[i].parent==0)&&(i!=s1))
{
minweight=ht[i].weight;
}
}
s2=i;
}
void creatHuffmanTree(HTNode ht[m])
{
int i=0;
for(i=n+1;i<=m;i++)
{
selectmin(HuffmanTree,s1,s2)
ht[s1].parent=i;
ht[s2].parent=i;
ht[i].lchild=s1;
ht[i].rchild=s2;
ht[i].weight=ht[s1].weight+ht[s2].weight;
}
}
void creatHuffmancode(HTNode ht[m],nodecode code[n])
{
char arr[n];
int start,p;
arr[n]='\0';
start=n-1;
printf("请输入字符");
for(i=1;i<=n;i++)
{
scanf("%c",&ncode[i].ch);
while((p=ht[i].parent)!=0)
{
if((ht[p].lchild)==i)
{
arr[start]='0';
}
else
{
arr[start]='1';
}
start--;
}
strcpy(ncode[i].code,arr);
}
printf("\n");
for(i=1;i<=n;i++)
{
printf("第%d个字符%c的编码是%s\n",i,ncode[i].ch,ncode[i].code);
}
}
int main()
{
int s1=0;
int s2=0;
HTNode HuffmanTree[m];
nodecode ncode[n];
InitHuffmanTree(HuffmanTree);
Inputweight(HuffmanTree);
creatHuffmanTree(HuffmanTree);
creatHuffmancode(HuffmanTree,code);
return 0;
}