A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 半醉半醒半浮生 中级黑马   /  2015-9-8 22:15  /  263 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

public class xuanZePaiXu {
public static void main(String[] args) {
int[] a = { 2, 6, 4, 5, 1, 7, 3 };
for (int i = 0; i < a.length; i++) {
int temp = 0;
for (int j = i + 1; j < a.length; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for (int t : a) {
System.out.println(t + ",");
}
}
}
您需要登录后才可以回帖 登录 | 加入黑马