冒泡排序法

2022-07-26 社会 77阅读
B 递增冒泡排序得原理是的是相邻2个元素比较如果为递减则交换第一趟16,9,4,25,15,2,13,18,17,5,8,249,16,4,25,15,2,13,18,17,5,8,24 9,4,16,25,15,2,13,18,17,5,8,24 9,4,16,25,15,2,13,18,17,5,8,24 9,4,16,15,25,2,13,18,17,5,8,24 9,4,16,15,2,25,13,18,17,5,8,249,4,16,15,2,13,25,18,17,5,8,249,4,16,15,2,13,18,25,17,5,8,249,4,16,15,2,13,18,17,25,5,8,249,4,16,15,2,13,18,17,5,25,8,249,4,16,15,2,13,18,17,5,8,25,249,4,16,15,2,13,18,17,5,8,24,25第一趟排序结束,毫无疑问,25是最大的数,在程序中就不需要再次于25进行比较了 第二趟9,4,16,15,2,13,18,17,5,8,24,254,9,16,15,2,13,18,17,5,8,24,254,9,16,15,2,13,18,17,5,8,24,254,9,15,16,2,13,18,17,5,8,24,254,9,15,2,16,13,18,17,5,8,24,254,9,15,2,13,16,18,17,5,8,24,254,9,15,2,13,16,18,17,5,8,24,254,9,15,2,13,16,17,18,5,8,24,254,9,15,2,13,16,17,5,18,8,24,254,9,15,2,13,16,17,5,8,18,24,25 最后结果B
(4,9,15,2,13,16,17,5,8,18,24,25)
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com