/* Inversion d'une chaine de caracteres        */

public class InversionChaineMethodeDichotomiqueEnConsole {

/////////////////////////////////////////////////

/* Inversion d'une chaine de caracteres        */

  static String inversionChaine(String st) {
    String s;
    String s1;
    String s2;
    int l1;
    int lst = st.length();
    if ( ( lst == 0 ) || ( lst == 1 ) ) {
      s = st; }
      else {
      l1 = lst/2;
      s1 = inversionChaine(st.substring(0,l1));
      s2 = inversionChaine(st.substring(l1,lst));
      s = s2+s1; }
    return s;
  }

/////////////////////////////////////////////////

/* Programme principal                         */

  public static void main(String [] args) {
    Console.setTitle("InversionChaineMethodeDichotomique");
    String st;
    String sti;
    Console.afficher("Chaine a inverser ? ");
    st = Console.saisirString();
    sti = inversionChaine(st);
    Console.afficherln("Chaine inversée   : ",sti);
  }
}