当前位置: 首页 > news >正文

各种排序333

冒泡排序 n方

public static void BubbleSort(int[] arr)
{int n = arr.Length;for (int i = 0; i < n - 1; i++){for (int j = 0; j < n - i - 1; j++){if (arr[j] > arr[j + 1]){int temp = arr[j];arr[j] = arr[j + 1];arr[j + 1] = temp;}}}
}

选择排序 n方

public static void SelectionSort(int[] arr)
{int n = arr.Length;for (int i = 0; i < n - 1; i++){int minIndex = i;for (int j = i + 1; j < n; j++){if (arr[j] < arr[minIndex]){minIndex = j;}}if (minIndex != i){int temp = arr[i];arr[i] = arr[minIndex];
http://www.lryc.cn/news/111246.html

相关文章:

  • [C++] 类与对象(中)完整讲述运算符重载示例 -- 日期类(Date) -- const成员
  • wonderful-sql 作业
  • Go学习第六天
  • opencv-34 图像平滑处理-2D 卷积 cv2.filter2D()
  • Java 克隆技术详解,深拷贝与浅拷贝的区别及实现
  • 包装器function
  • Django Rest_Framework(三)
  • 总结 IO、存储、硬盘、文件系统相关常识
  • JavaScript、深入浅出Node.js前端技能汇总
  • use gnustep objective-c
  • 8.15锁的优化
  • 单片机复位电路分析
  • 公文写作技巧:“三面镜子”写作提纲60例
  • useEffect中的函数会执行2次原因
  • 更新k8s环境支付系统支付证书
  • C#的yield
  • 外卖多门店小程序开源版开发
  • 打印图案、
  • # Windows 环境下载 Android 12源码
  • 【运维面试】Docker技术面试题总结
  • CNN成长路:从AlexNet到EfficientNet(01)
  • 使用IDEA操作Mysql数据库
  • ChatGPT下架官方检测工具,承认无法鉴别AI内容
  • Java通过实例调用getClass()方法、类名.class操作、通过运行时类获取其它信息
  • UE5+Paperzd问题
  • K8S系列文章之 自动化运维利器 Ansible
  • Julia 字典和集合
  • devops-发布vue前端项目
  • 使用正则表达式设置强密码
  • epoll、poll、select的原理和区别