Professional Documents
Culture Documents
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
struct arb_multicai
{
int cheie;
int nr_copii;
arb_multicai **copii;
} *vect_mult[100], *rad;
struct arb_binar
{
int cheie;
arb_binar *fiu;
arb_binar *frate;
} *vect_bin[100];
void arbore_multicai()
{
//Parintele
int i, x;//x=c
for (i = 1; i <= nr; i++)
{
if (parinte[i] == -1)
{
rad = vect_mult[i];
}
else
{
vect_mult[parinte[i]]->nr_copii = vect_mult[parinte[i]]->nr_copii
+ 1;
x = vect_mult[parinte[i]]->nr_copii;
vect_mult[parinte[i]]->copii[x] = vect_mult[i];
}
}
}
int i;
if (p != NULL)
{
if (p->nr_copii == 0)
printf("\n");
arbore(p->copii[i]);
}
}
}
printf("\n");
for (int j = 1; j <= depth; j++)
printf(" ");
printf("%d", ch);
if (vect_bin[ch]->fiu != NULL)
pretty_print(vect_bin[ch]->fiu->cheie, depth + 1);
if (vect_bin[ch]->frate != NULL)
pretty_print(vect_bin[ch]->frate->cheie, depth);
void main()
{
int i;
vect_bin[i] = (arb_binar*)malloc(sizeof(arb_binar));
vect_bin[i]->cheie = i;
vect_bin[i]->fiu = vect_bin[i]->frate = NULL;
}
getchar();