Java經典程式碼-氣泡排序
/**
* @author ManScript
*
*/
public class Maopao {
static int [] scores={5,10,5,2,9,3,8};public static void main(String[] args) {
for(int i=0;i<scores.length;i++){
for(int j=0;j<scores.length-i-1;j++){
if(scores[j]>scores[j+1]){
int temp=scores[j];
scores[j]=scores[j+1];
scores[j+1]=temp;
}
}
}
System.out.println(Arrays.toString(scores));
}
}