/* *Classname Dicho5 *Version 1 *Date *Copyright */ class Dicho5{ private int n=5; /*taille max du tableau*/ private int [] tab=new int[5]; /*le tableau*/ public Dicho5(int [] tableau){ int i; for (i=0;i<5;i++) { tab[i]=tableau[i]; } } public boolean cherche(int x){ /*recherche dichotomique */ int i,j,m; boolean found; i=0; j=n; m=0; found=false; while (i<=j) { m=(i+j+1)/2; if (tab[m]<=x) i=m+1; else j=m-1; } if (1<=i && i<=n) { return (tab[m]==x); } else { return false; } } }