1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| public static boolean CompareDico(char t[][],char t1[]) {
int a = 0;
int b = t.length-1;
int ind = (a+b)/2;
int val = dicho(t,t1,ind);
while(val!=0||b!=0||a!=t.length-1){
if(val==1) {
b=ind;
}
if(val==-1) {
a=ind;
}
val = dicho(t,t1,ind);
}
if(val==0){
return true;
}else{
return false;
}
}
public static int dicho (char t[][],char t1[],int ind) {
for(int i=0;i<t[ind].length;i++) {
if (t[ind][i]>t1[i]){
return 1;
}
if (t[ind][i]<t1[i]) {
return -1;
}
}
return 0;
} |
Partager