for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr.length-i-1; j++) { if (arr[j]>=arr[j+1]) { int temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } }
for (int i = 0; i < arr.length - 1; i++) { for (int j = i; j < arr.length - 1 - i; j++) { if (arr[i]>arr[j]) { int temp; temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } }
int temp = 0; for (int i = 0; i < arr.length; i++) { for (int j = i; j < arr.length; j++) { if (arr[i]>arr[j]) { temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } }
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题