哈夫曼树里的工作指针问题

小弟不晓得怎么样才能让工作指针循环指向哈夫曼树里权值最小的两个数,思路是冒泡排序把他们按权值大小,从小到大放在下标1开头的数组里,再让s1,2两个工作指针每一次循环加加。但是指针加加这里我实现不了,求助

#include <stdio.h>
#include <stdlib.h>

typedef struct hf
{
    int weight;
    int parent,lchild,rchild;
}hf,*hftree;
void createhf(hf *H,int n)
{
    if(n<=1)
        exit(1);
    int m=2*n-1,i;
    H=(hftree)malloc((m+1)*sizeof(hf));
    for(i=1;i<=m;i++)
    {
        H[i].weight=0;
        H[i].parent=0;
        H[i].lchild=0;
        H[i].rchild=0;
    }
    printf("请输入每个叶子结点的权值");
    for(i=1;i<=n;i++)
    {
        scanf("%d",&H[i].weight);
    }

}

void select(hf *H,int n,hftree s1,hftree s2)
{
    int i,j,temp;
    s1=(hftree)malloc(sizeof(hf));
    s2=(hftree)malloc(sizeof(hf));
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(H[i].weight>H[j].weight)
            {
                temp=H[i].weight;
                H[i].weight=H[j].weight;
                H[j].weight=temp;
            }
        }
    }
    s1=H[];//这一段不会写QAQ,怎么让指针循环指向最小的两个数呢
    s2=s1;
}

void hft(hf *H,int n,hftree s1,hftree s2)
{
    int i,m=2*n-1;
    for(i=n+1;i<=m;i++)
    {
        select(H,n,s1,s2);
        H[s1].parent=i;
        H[s2].parent=i;
        H[i].lchild=s1;
        H[i].rchild=s2;
        H[i].weight=H[s1].weight+H[s2].weight;
    }
}
void show(hf *H,int n)
{
    int i;
    int m=2*n-1;
    for(i=1;i<=m;i++)
    {
        printf("结点序号 %d 权重 %d parent %d lchild %d rchild %d\n",i,H[i].weight,H[i].parent,H[i].lchild,H[i].rchild);
    }
}
int main()
{
    hf H;
    hftree s1,s2;
    int n;
    printf("开始构建哈夫曼树\n");
    printf("请输入哈夫曼树的叶子结点的个数:");
    scanf("%d",&n);
    createhf(&H,n);
    select(&H,n,s1,s2);
    hft(&H,n,s1,s2);
    show(&H,n);
    printf("Hello world!\n");
    return 0;
}


https://blog.csdn.net/move_now/article/details/53398753