昌泡排序的结果从小到大
2013-08-12 15:55
176 查看
public class MySort{ public static void main(String[] args){ int score[] = {67, 69, 75, 87, 89, 90, 99, 100}; System.out.print("排序前结果:"); for(int a = 0; a < score.length; a++){ System.out.print(score[a]+" " ); } for (int i = 0; i < score.length -1; i++){ //最多做n-1趟排序 for(int j = 0 ;j < score.length - i - 1; j++){ //对当前无序区间score[0......length-i-1]进行排序(j的范围很关键,这个范围是在逐步缩小的) if(score[j] < score[j + 1]){ //把小的值交换到后面 int temp = score[j]; score[j] = score[j + 1]; score[j + 1] = temp; } } } System.out.print("最终排序结果:"); for(int a = 0; a < score.length; a++){ System.out.print(score[a] + " "); } } }
相关文章推荐
- 以行为单位对字符串变量下标为奇数位置上的字符按其ASCii值从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组xx中
- PHP之10个整数,从小到大排序,输出排序结果
- 主函数创建5个学生的数组,写一个排序函数,让学生按姓名从小到大排序,主函数输出排序后的结果。
- //1.主函数创建5个学生的数组,写一个排序函数,让学生按姓名从小到大排序,主函数输出排序后的结果。
- (C语言-结构体)主函数创建5个学生的数组,写一个排序函数,让学生按姓名从小到大排序,主函数输出排序后的结果。
- 输入一串字符,要求数字从小到大,字母从a到z排序,输出字母和数字的排序结果。
- 主函数创建5个学生的数组,写一个排序函数,让学生按姓名从小到大排序,主函数输出排序后的结果
- 三个数排序。要求输入三个整数,按逗号隔开,把它们从小到大排列,输出结果用空格隔开。
- Lucene3.0结果排序原理+操作+示例
- 个有10个元素的整型一维数组,用户输入9个数据,调用函数,对数组元素进行从小到大排序后,在函数中输入一个数,插入到数组中正确的位置,并输出
- js冒泡排序,数组从小到大排序
- 解决模糊查询的结果记录排序问题
- 从小到大排序
- 输入6个字符串,并对它们按从小到大的顺序排序后输出。
- MongoDB文档查询-分页查询(limit、skip)与查询结果排序(sort)
- 编写一个void sort(int*x,int n)实现将x数组中的n个数据从大到小排序。n及数组元素在主函数中输入。将结果显示在屏幕上并输出到文件
- 把1-9这9个数字按从小到大的顺序排列 ,中间添上“+”和"-"可以计算的结果等于100的程序;
- mysql的in选择结果过,按照in里面的排序排序
- 华为:对一个数组,将数组中偶数从大到小排序,奇数从小到大排序,奇数和偶数交叉着放,且输出数组第一位放奇数
- sql按查询结果第一列排序 (order by+数字)