Java冒泡排序

来源:互联网 发布:大凤号航空母舰知乎 编辑:程序博客网 时间:2024/06/07 06:18

Java代码

package test;public class test {public static void main(String args[]){char ch1 = 'a';System.out.println("ch1 = " + ch1);int score[] = {1, 3, 5, 2, 4, 7};for(int i = score.length; i > 0; i--){for(int j = 0; j < i - 1; j++){if(score[j] > score[j+1]){int temp = score[j];score[j] = score[j+1];score[j+1] = temp;}}}for(int i = 0; i < score.length; i++){System.out.println(score[i]);}}}


冒泡排序
0 0
原创粉丝点击