冒泡排序
2015-10-13 14:12
411 查看
[code]package com.hongyewell.com; /** * 冒泡排序 * 借助变量temp来对数组中相邻的两个元素进行比较 * @author yeye * */ public class BubbleSort { public static void main(String[] args){ int arr[] ={2,3,4,8,9,10,1,5,6,7}; int temp; for(int i=0;i<10;i++){ temp = arr[i]; for(int j=0;j<10;j++){ if(arr[i]<arr[j]){ temp =arr[j]; arr[j]=arr[i]; arr[i]=temp; } } } for(int n:arr){ System.out.println(n); } } }
相关文章推荐
- MySQL 5.6 & 5.7最优配置模板
- Zabbix 集成 OneAlert 实现全方位告警
- JAVA从入门到精通读书笔记 第二章
- android 时间计时器
- spark学习3-CountOnce
- 大型网站之分布式会话管理
- 卓越管理的实践技巧(1)如何进行有效的指导 Guidelines for Effective Coaching
- php手册之变量范围
- Spring+SpringMVC+Mybatis整合系列(二)Eclipse新建Maven web项目
- HDU 1312 Red and Black(dfs)
- GCC -o -c选项的功能
- 技术学习
- stackview 属性解析
- js闭包(二)
- ajax无刷新方式收集表单并提交表单
- Microsoft JET Database Engine 错误 '80004005'不是一个有效的路径。 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器。
- spice-vdagent
- LeetCode-Longest Palindromic subString(java)
- Spring 4.2框架中注释驱动的事件监听器详解
- iOS求生之路三(定时器)