/* Inversion d'une chaine de caracteres        */

public class InversionChaineCaracteresEnConsole {

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

/* Inversion d'une chaine de caracteres        */

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

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

/* Programme principal                         */

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