#include <stdio.h>
#include <stdlib.h>
#include<assert.h>
typedef struct{
int Weight;
int parent;
int lchild;
int rchild;
}HufMan;
int HufManFindmin(HufMan* hf){
int i = 0;
int idx;
int min = 1000;
while(hf[++i].Weight!=0){
(hf[i].parent == 0)?
min = (min>hf[i].Weight?(idx = i,hf[i].Weight):min)
:0;
}
return idx;
}
int main () {
HufMan hf[50];
memset(hf,0,sizeof(hf));
for (int i = 1 ; i <= 25; i++){
hf[i].Weight = rand()%100;
printf("%d ",hf[i].Weight);
}
hf[0].Weight = 26;
for(1;hf[0].Weight <= 50;hf[0].Weight++){
int c = hf[0].Weight;
int child = HufManFindmin(hf);
hf[child].parent = c;
hf[c].lchild = 0;
}
printf("Hello JSRUN! \n\n - from C .");
return 0;
}