import java.awt.*; public class Tri { private double valeur; private Tri filsGauche; private Tri filsDroit; private boolean estVide; public Tri() { this.estVide = true; } public Tri(double valeur) { this.estVide = false; this.valeur = valeur; } public void ajouter(double valeur) { if (this.estVide) { this.valeur = valeur; this.estVide = false; return; } if (valeur < this.valeur) { if (this.filsGauche == null) { this.filsGauche = new Tri(); } filsGauche.ajouter(valeur); } else { if (this.filsDroit == null) { this.filsDroit = new Tri(); } filsDroit.ajouter(valeur); } } public String toString() { String aRenvoyer = ""; if (this.filsGauche != null) { aRenvoyer += this.filsGauche.toString(); } aRenvoyer += this.valeur + " "; if (this.filsDroit != null) { aRenvoyer += this.filsDroit.toString(); } return aRenvoyer; } public static void main(String[] args) { Tri racine = new Tri(); for (String chaine : args) { racine.ajouter(Double.parseDouble(chaine)); } System.out.println(racine); } }