排序算法
来源:互联网 发布:桌面 知乎 编辑:程序博客网 时间:2024/05/16 13:42
冒泡排序算法:
public static void main(String[] args) { int [] score = new int[5]; for (int i = 0; i < score.length; i++) { score[i] = new Random().nextInt(100); System.out.print(score[i] + " " +i + " " + "\n"); } for (int i=0; i < score.length; i++) { for (int j = 0; j < score.length; j++) { if (score[i] < score[j]) { int temp = score[i]; score[i] = score[j]; score[j] = temp; } } for (int y = 0; y < score.length; y++) { System.out.print(score[y] + " "); } System.out.print("\n"); } for (int i = 0; i < score.length; i++) { System.out.print(score[i] + " "); } }
阅读全文
0 0
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 排序算法
- 为什么Dialog不能用Application的Context
- string和vector易错点
- 怎么去掉我的电脑中的微云盘符?
- ansible 自定义iventory源
- 浓墨重彩之MySQL-03-数据操作
- 排序算法
- 682. Baseball Game
- codevs 2218 补丁vs错误
- 什么是Intellij IDEA
- ajax实现图片轮番滚动
- [NOIP2017模拟]姓名匹配
- MVP中存在的内存泄漏问题
- cookie、session、token的理解
- golang基础-new_make、recover_panic、append、闭包