`

排序啊啊啊啊

    博客分类:
  • java
阅读更多
package cn.mldn;

public class ArrayDemo06 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int score[] = {5,7,4,3} ;		// 使用静态初始化声明数组
		int temp = 0;
		
		for(int i = 0; i < score.length-1; i++) {
			for(int j = i + 1; j < score.length; j++) {
				if(score[i] > score[j]) {
					temp = score[i];
					score[i] = score[j];
					score[j] = temp;
				}
			}
		}
		
		for(int i = 0; i < score.length; i++) {
			System.out.print(score[i] + "  ");
		}
	}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics