java三種面試手寫常考排序:
一.下面展示冒泡排序(偽代碼),
// 先定義陣列:
int []a={2,4,5,7,6,1,3};
// 進行遍歷和排序
for(int i=0;i<a.length;i++){
for(int j=0;j<a.length-1-i;j++{
if(a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/288294.html
標籤:其他
下一篇:Java常見資料結構
