Logo Pastebin.fr
Pastebin

Retrouvez, créez et partagez vos snippets en temps réel.

---

from math import *

arbre=[
"A",
["B", ["E"],["F"]],
["C", ["G"],["H"],["I"]],
["D"]
]

arb=[7,3,8,9,2,1,5,10,13,15,17,12,14,None,None]

def afficher(arbre, marge):
    print(" " * marge + arbre[0])

    for sous_arbre in arbre[1:]:
        afficher(sous_arbre, marge + 4)

    return ""

def affichage(arbre, i=0, debut_niveau=0, taille_niveau=1):
    if i >= len(arbre):
        return

    print(" ".join(str(x) for x in arbre[debut_niveau:i+1]))

    if i == debut_niveau + taille_niveau - 1:
        affichage(arbre, i + 1, i + 1, taille_niveau * 2)
    else:
        affichage(arbre, i + 1, debut_niveau, taille_niveau)

Créé il y a 3 semaines.

Rechercher un Pastebin

Aucun paste trouvé.