class TableDichotomique {
  // \esc{Recherche Linéaire, voir page \pageref{prog:recherche-lineaire}}

  final static int N = 6;
  static String nom[] = new String[N+1];
  static int tel[] = new int[N+1];

  static void Initialisation() {
// \esc{Recherche dichotomique, voir page \pageref{prog-recherche-dichotomique}} 

    nom[0] = "anne"; tel[0] = 2702;
    nom[1] = "laure"; tel[1] = 2701;
    nom[2] = "paul"; tel[2] = 2811;
    nom[3] = "pierre"; tel[3] = 2805;
    nom[4] = "roger"; tel[4] = 4501;
    nom[5] = "yves"; tel[5] = 2806;
  }

  static int RechercheDichotomique (String x) {

    int   i, g, d, cmp;

    g = 0; d = N-1;
    do {
        i = (g + d) / 2;
        cmp = x.compareTo(nom[i]);
        if (cmp == 0)
            return tel[i];
        if (cmp < 0)
            d = i - 1;
        else 
            g = i + 1;
    } while (g <= d);
    return -1;
}

  public static void main(String args[]) {
      
    Initialisation();
    if (args.length == 1)
        System.out.println (RechercheDichotomique(args[0]));
  }
}

