冒泡排序
来源:互联网 发布:淘宝500字差评范文 编辑:程序博客网 时间:2024/06/08 15:09
public class BubbleSort{public static void main(String args[]){int a[] = {10,5,10,2};System.out.println("this is bubblesort:");BubbleSort(a);output(a);}public static void output(int a[])//输出{int i;for(i = 0; i < a.length; i++){System.out.print(a[i] + " ");}System.out.println();}public static void BubbleSort(int a[]){int i, j;for(i = 0; i < a.length; i++){for(j = 0; j < a.length -1 - i; j++){int temp;if(a[j] > a[j + 1])//交换两个数{temp = a[j + 1];a[j + 1] = a[j];a[j] = temp;}}}}}
阅读全文
0 0
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- Log:what every software enginner should know about real-time data's unifying abstraction
- Java基础---条件语句、Switch、while、do while、for、break、continue
- MyBaits和HiBernate的区别
- 算法提高 ADV-97 十进制数转八进制数
- 定时向指定邮箱发送邮件
- 冒泡排序
- 计算圆周率
- String类
- Zookeeper系列(一)
- python字符串函数strip()
- js实现集合方法
- 单例的两种类型,以及介绍
- The study of Class and Instance in Python(20170918)
- LeetCode 80. Remove Duplicates from Sorted Array II