有沒有大神幫忙解讀一下,這個(gè)for循環(huán)怎么走的,先走哪再走哪,盡量詳細(xì)點(diǎn),謝
int[] arr = {99,44,77,33,55,88,66};
??for(int x = arr.length-1; x >= 0; x--){
???????for(int y = x-1; y >= 0; y--){
????????????if(arr[y] > arr[x]){
?????????????int temp = arr[y];
?????????????arr[y] = arr[x];
?????????????arr[x] = temp;
????????????}
???????}
????????System.out.print(arr[x]+",");
????}
2019-10-29
第一層for循環(huán)第一次循環(huán)
?此時(shí)x=6,y=5,進(jìn)入第二層for循環(huán),循環(huán)至y=0;
進(jìn)入第一次循環(huán)的第二次循環(huán),此時(shí)x=5,y=4
依次類推