当前位置:网站首页>Bubble sort
Bubble sort
2022-06-24 23:21:00 【Programmer Jiuan】
Bubble sort
import java.util.Arrays;
public class MaoPao{
public static void main(String[] args) {
/* for the first time 3,10,24,12; 3,10,24,12; 3,10,12.24; The second time 3,10,12 3,10,12 third time 3,10 */
int [] num = {
10,3,24,12};
for (int i = num.length - 1; i > 0; i--) {
// Number of times to queue
for (int j = 0; j < i; j++) {
int temp;// Temporary variables store data
if (num[j] > num[j + 1]) {
temp = num[j];// Save the first value
num[j] = num[j + 1];// Give the second array to the first
num[j + 1] = temp;// Give the stored data to the second number
}
}
}
System.out.println(Arrays.toString(num));
}
}
边栏推荐
猜你喜欢

SimpleDateFormat 格式化和解析日期的具体类

Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis

01_ Getting started with the spingboot framework

Getting started with the go Cobra command line tool

Mousse shares listed on Shenzhen Stock Exchange: becoming popular by mattress and "foreign old man", with a market value of 22.4 billion yuan

【js】-【數組、棧、隊列、鏈錶基礎】-筆記

【UVM入门 ===> Episode_8 】~ Sequence 和 Sequencer、Sequence 层次化

03_SpingBoot 核心配置文件

Learn about redlock
![[introduction to UVM== > episode_8] ~ sequence and sequencer, sequence hierarchy](/img/d0/7d78b00e4f6ad1e8efb73a5d472b09.png)
[introduction to UVM== > episode_8] ~ sequence and sequencer, sequence hierarchy
随机推荐
257. 关押罪犯
斐波那契
02_ Springboot starter case
golang map clear
Selection (028) - what is the output of the following code?
Construction equipment [5]
File contains vulnerability issues
laravel 创建 service层
案例解析:用「度量」提升企业研发效能|ONES Talk
Detailed explanation of online group chat and dating platform project (servlet implementation)
安装IBM CPLEX学术版 academic edition | conda 安装 CPLEX
Financial management [1]
Pousser l'information au format markdown vers le robot nail
Use of laravel verifier
07_SpingBoot 实现 RESTful 风格
点的螺旋距离
华为机器学习服务语音识别功能,让应用绘“声”绘色
宁德时代定增450亿:高瓴认购30亿 曾毓群仍控制23%股权
Learn about redlock
【js】-【數組、棧、隊列、鏈錶基礎】-筆記