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
| public class main {
public static void main(String[] args) {
char [] tj = new char [] {'T','T','G','T','T','T','A','C','G','T','G','C','A','G','G','A','G','C','A','T'};
char [] ti = new char [] {'T','G','G','A','G','C','A','T','T','G','T','T','T','A','C','G','T','G','C','A','G','G','A','G','C','A','T'};
int j = tj.length-1;
int i = ti.length-1;
if ( i>=0 && j>=0 ) {
do {
if (tj[j]==ti[i]){
if ( j>0 ) { // on ne décrémente plus dès qu'on a atteint 0
j--;
}
}
if ( i>0 ) { // le décrément étant fait dans les 2 cas (if et else), autant le sortir du if/else
i--;
}
System.out.println("i="+i+" "+"j="+j);
} while(i>0 || j>0) ; // tant que l'un des indices n'est pas 0
}
}
} |
Partager