当前位置:网站首页>冒泡排序
冒泡排序
2022-06-24 19:42:00 【程序员久安】
冒泡排序
import java.util.Arrays;
public class MaoPao{
public static void main(String[] args) {
/* 第一次 3,10,24,12; 3,10,24,12; 3,10,12.24; 第二次 3,10,12 3,10,12 第三次 3,10 */
int [] num = {
10,3,24,12};
for (int i = num.length - 1; i > 0; i--) {
//要排的次数
for (int j = 0; j < i; j++) {
int temp;//临时变量储存数据
if (num[j] > num[j + 1]) {
temp = num[j];//把第一个值给存起来
num[j] = num[j + 1];//把第二个数组给第一个
num[j + 1] = temp;//在把存起来的数据给第二个数
}
}
}
System.out.println(Arrays.toString(num));
}
}
边栏推荐
- Laravel add helper file
- 【js】-【數組、棧、隊列、鏈錶基礎】-筆記
- Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!
- How to submit the shopee opening and settlement flow?
- gocolly-手册
- Sword finger offer 42 Maximum sum of successive subarrays
- Financial management [2]
- Research Report on research and investment prospects of China's container coating industry (2022 Edition)
- Research Report on solar battery charger industry - market status analysis and development prospect forecast
- 加分利器 不负所托 | 知道创宇获攻防演练防守方感谢信!
猜你喜欢

02_SpingBoot 入门案例

canvas 实现图片新增水印

07_ Springboot for restful style

研究生宿舍大盘点!令人羡慕的研究生宿舍来了!

非单文件组件
Mycms we media CMS V3.0, resource push optimization, new free template

RT-thread使用rt-kprintf

vulnhub DC: 2

The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!
![[postgraduate entrance examination English] prepare for 2023, learn list9 words](/img/2d/9ff691c9ff50fba2df73f726db26f2.jpg)
[postgraduate entrance examination English] prepare for 2023, learn list9 words
随机推荐
go Cobra命令行工具入门
Research Report on market supply and demand and strategy of ceiling power supply device industry in China
docker-mysql8-主从
Dig deep into MySQL - resolve the non clustered index of MyISAM storage engine
剑指 Offer 13. 机器人的运动范围
23研考生注意啦!备考期间最容易中招的骗局,居然是它们?!
Market trend report, technical innovation and market forecast of solar roof system in China
docker安装redis-简单而无坑
Recommended movies: Northeast tiger, licorice pizza
数字IC设计经验整理(二)
Laravel pagoda security configuration
Construction equipment [4]
剑指 Offer 42. 连续子数组的最大和
Blogs personal blog project details (servlet implementation)
RT-thread使用rt-kprintf
[text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
Laravel study notes
laravel学习笔记
laravel 验证器的使用
Detailed explanation of online group chat and dating platform project (servlet implementation)