首页 >>  正文

冒泡排序简单例题

来源:baiyundou.net   日期:2024-08-24

政宏蚁4764一个冒泡排序问题 -
轩帖征19221188205 ______ 1. 四遍加工(非改进型的冒泡排序)2. 第一次交换2次 第一遍:22比94小不交换94比17大交换得序列 22,17,94,125,6394比125小不交换125比63大交换得序列22,17,94,63,125 第二遍:22比17大交换得序列17,22,94,63,12522比94小不交换94比63大交换得序列17,22,63,94,125 第三遍:显然序列已经有序不会出现交换 第四遍:如果是改进型冒泡排序则此时已经标识上一轮无数据交换,则不会进行第四遍,否则就会进行第四遍比较,同样没有交换.

政宏蚁4764冒泡排序练习 -
轩帖征19221188205 ______ 原题问第k轮后的结果,不是第k步后的结果.你的if(i==k)放的不是地方.下面是我改正后的for循环:for(j=0;j<n-1;j++) { if(j==k) break; else for(i=0;i<n-1-j;i++) { if(a[i+1]>a[i]) temp=a[i],a[i]=a[i+1],a[i+1]=temp; } } 最后附带一点,你不觉得你最后那个...

政宏蚁4764求一个C语言冒泡排序程序,简单的 -
轩帖征19221188205 ______ main() { int i,j,temp; int a[10]; for(i=0;i<10;i++) scanf ("%d,",&a[i]); for(j=0;j<=9;j++) { for (i=0;i<10-j;i++) if (a[i]>a[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp;} } for(i=1;i<11;i++) printf("%5d,",a[i] ); printf("\n"); }

政宏蚁4764冒泡排序举个例子. -
轩帖征19221188205 ______ public class test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int temp = 0; String str = "51,35,33,55,67,64"; String[] strTemp = str.split(","); for(int i = 0;i<strTemp.length;i++){ for(int j = i+1;j<...

政宏蚁4764写一个for循环,冒泡排序 -
轩帖征19221188205 ______ public static void main(String args[]) { int[] m = { 2, 8, 43, 3, 33, 1, 35, 34, 6, 9 }; int[] n = sort(m); for (int i = 0; i < m.length; i ) { System.out.println(n[i] "\n"); } } /* 冒泡排序算法 */ public static int[] sort(int[] m) { int intLenth = m.length; /*执行intLenth...

政宏蚁4764C语言数组冒泡排序法题目求解 -
轩帖征19221188205 ______ 展开全部#include "stdio.h" void main() { int Acad[5]={6001,6002,6003,6004,6005}, Math[5]={89,90,84,74,85}, English[5]={84,95,87,85,95}, VC[5]={70,94,85,91,76}, ASP[5]={85,83,70,79,80}, total[5]={0,0,0,0,0}, sort[5]={1,2,3,4,5}; char Name[5][6]...

政宏蚁4764C语言简单程序冒泡排列 -
轩帖征19221188205 ______ 第一 第二5261个for循环不对 应该用for(i=0;i<6-j;i++) 第二 你判断也不对,照你的判断,t=a[i]; a[i+1]=a[i] ; a[i+1]=t; a[i+1]被覆盖掉了,不再有a[i+1]这个值 还有,你4102的冒泡排序是1653最好是用大于,你要小于的话,大数就到前面了,小数沉...

政宏蚁4764冒泡排序法 -
轩帖征19221188205 ______ 以数组中的10个数从小到大升序排序为例. 第一个程序,大家都会的: main() { int a[10]; int i,j; for(i=0;i<10;i++)a[i]=9-i; for(i=0;i<9;i++) for(j=0;j<9;j++) if(a[j]>a[j+1]) { int t; t=a[j]; a[j]=a[j+1]; a[j+1]=t; } for(i=0;i<10;i++) printf("\n%d",a[i]); } ...

政宏蚁47645、已知数据序列为(9,20,6,31,24),对该数据序列进行排序,写出冒泡排...
轩帖征19221188205 ______ public void bubbleSort(int a[]) { //数组的冒泡排序 int n = a.length; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (a[j] > a[j + 1]) { int temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } }

(编辑:自媒体)
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图 @ 白云都 2024