冒泡排序
来源:互联网 发布:从数组中删除指定元素 编辑:程序博客网 时间:2024/05/23 18:31
//冒泡排序(Bubble Sort)的基本思想是:将相邻的记录的关键码进行比较,若前面记录的关键码大于后面记录的关键码,则将它们交换,否则不交换。
using UnityEngine;using System.Collections;public class MaoPao : MonoBehaviour { // Use this for initialization public int temp = 0; public int[] arr = { 23, 44, 66, 76, 98, 11, 3, 9, 7 }; IEnumerator Start () { for (int i = 0; i < arr.Length - 1; i++) {//# region将大的数字移到数组的arr.Length-1-i for (int j = 0; j < arr.Length - 1 - i; j++) { if (arr[j] > arr[j + 1]) { temp = arr[j + 1]; arr[j + 1] = arr[j]; yield return new WaitForSeconds(3f); arr[j] = temp; print(""+ temp); } }//#endregion }}}
0 0
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- Android--UI之DatePicker、TimePicker...
- 系统移植的四大步骤
- Oracle语句大全
- adbd cannot run as root in production builds的解决方法
- 剑指offer 面试题5 从尾到头打印链表 java版答案
- 冒泡排序
- 如何封装 opengl 流程 – 以为android-opengl-canvas例
- C语言二级指针
- mysql 数据库引擎
- spring自定义注解
- UITableViewCell中嵌套UITableView,用UITextView加载HTML数据
- CentOS学习20_centos 6.4 NTP服务器的搭建过程
- Multisim使用中出现的问题以及解决
- AndroidStudio常用插件及使用