当前位置:网站首页>八大排序----------------冒泡排序
八大排序----------------冒泡排序
2022-07-29 05:23:00 【李汁汁】
冒泡排序的具体过程 如gif图 利用双指针 进行一个一个排序 这样每次都得到第一大的值放到右面
public static void main(String[] args) {
int[] arr = {88,66,77,99,33,22};
Sort(arr);
System.out.println("排序后的结果: "+Arrays.toString(arr));
}
public static void Sort(int[] arr) {
int temp = 0;
for (int i = 0; i < arr.length-1; i++) {
for(int j=0;j<arr.length-1;j++) {
if(arr[j]>arr[j+1]) {
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1]= temp;
}
}
}
}
边栏推荐
- QT learning notes QT model/view
- 【软件工程之美 - 专栏笔记】21 | 架构设计:普通程序员也能实现复杂系统?
- 2022春招——芯动科技FPGA开发岗笔试题(原题以及心得)
- 华为云14天鸿蒙设备开发-Day2编译框架
- FPGA based: moving target detection (supplementary simulation results, available)
- 基于51单片机的四路抢答器仿真
- HAL库学习笔记-12 SPI
- 【软件工程之美 - 专栏笔记】29 | 自动化测试:如何把Bug杀死在摇篮里?
- HR must ask questions - how to fight with HR (collected from FPGA Explorer)
- Hal learning notes - Basic timer of 7 timer
猜你喜欢
随机推荐
SimpleFOC调参3-PID参数整定攻略
Migration learning notes - adaptive component analysis
【软件工程之美 - 专栏笔记】29 | 自动化测试:如何把Bug杀死在摇篮里?
NFC双向通讯13.56MHZ非接触式阅读器芯片--Si512替代PN512
基于51单片机的DAC0832波形发生器
传统模型预测控制轨迹跟踪——波浪形轨迹(功能包已经更新)
Based on stc51: schematic diagram and source code of four axis flight control open source project (entry-level DIY)
【软件工程之美 - 专栏笔记】28 | 软件工程师的核心竞争力是什么?(下)
【软件工程之美 - 专栏笔记】23 | 架构师:不想当架构师的程序员不是好程序员
倾角传感器精度校准检测
Model building in pytorch
STM32FF030 替代国产单片机——DP32G030
噪声传感器工作原理是什么?
基于STC51:四轴飞控开源项目原理图与源码(入门级DIY)
【软件工程之美 - 专栏笔记】22 | 如何为项目做好技术选型?
新能源充电桩后台管理系统平台
华为云14天鸿蒙设备开发-Day5驱动子系统开发
ArduinoIDE + STM32Link烧录调试
QT learning notes - Import and export of Excel
基于FPGA:多目标运动检测(手把手教学①)