Afficher un arbre n-aire en c
sinzo
Messages postés
91
Date d'inscription
Statut
Membre
Dernière intervention
-
nabilo -
nabilo -
Bonjour,
j'aimerais bien que quelqu'un de "pro" me traduise ce code en langage C , merci d'avance :
voici le code :
procedure arbre.dessine(en_cours: noeud; limg, old_x, old_y: integer);
var x, y, nb: integer;
i: char;
begin
//nb:=compter_terminaux(courant); // effet joli
nb := compter_terminaux(en_cours);
x := limg + (50 * nb) div 2;
y := old_y + 80;
if en_cours <> tete then
with form1.image1.picture.bitmap.canvas do
begin
textout(x, y, en_cours.lettre);
en_cours.x := x; en_cours.y := y;
moveto(x, y - 5); lineto(old_x, old_y);
end;
for i := 'A' to 'Z' do
if en_cours.fils[i] <> nil then
begin
nb := compter_terminaux(en_cours.fils[i]);
dessine(en_cours.fils[i], limg, x, y + 20);
limg := limg + nb * 50;
end;
end;
j'aimerais bien que quelqu'un de "pro" me traduise ce code en langage C , merci d'avance :
voici le code :
procedure arbre.dessine(en_cours: noeud; limg, old_x, old_y: integer);
var x, y, nb: integer;
i: char;
begin
//nb:=compter_terminaux(courant); // effet joli
nb := compter_terminaux(en_cours);
x := limg + (50 * nb) div 2;
y := old_y + 80;
if en_cours <> tete then
with form1.image1.picture.bitmap.canvas do
begin
textout(x, y, en_cours.lettre);
en_cours.x := x; en_cours.y := y;
moveto(x, y - 5); lineto(old_x, old_y);
end;
for i := 'A' to 'Z' do
if en_cours.fils[i] <> nil then
begin
nb := compter_terminaux(en_cours.fils[i]);
dessine(en_cours.fils[i], limg, x, y + 20);
limg := limg + nb * 50;
end;
end;
A voir également:
- Afficher un arbre n-aire en c
- Afficher appdata - Guide
- Afficher google en page d'accueil - Guide
- Afficher taille dossier windows - Guide
- Windows 11 afficher d'autres options - Guide
- Afficher mot de passe wifi android - Guide
1 réponse
bonjour , svp jai besoin d'aide par rapport a l'affichage d'un arbre n aire. Je vx afficher mon arbre sous la forme suivante par ex :
et voici ce que jai fait :
void afficher_arbre(struct noeud *p)
{ printf("\n%c",p->c);
if(p->fils!=NULL)
{ printf("\n|");
afficher_arbre(p->fils);
}
if(p->frd!=NULL)
{ printf(" --");
afficher_arbre(p->frd);
}
}
merci d'avance de votre aide
racine de l'arbre / / A-----C-------E | | | R H C | / | B A---I O | | | | R T E L | | | E N E
et voici ce que jai fait :
void afficher_arbre(struct noeud *p)
{ printf("\n%c",p->c);
if(p->fils!=NULL)
{ printf("\n|");
afficher_arbre(p->fils);
}
if(p->frd!=NULL)
{ printf(" --");
afficher_arbre(p->frd);
}
}
merci d'avance de votre aide
youscoul
Messages postés
125
Date d'inscription
Statut
Membre
Dernière intervention
4
t'es parvenu à afficher ton arbre ??
nabilo
je pense que c juste ce que t'as fait!!