当前位置:网站首页>冒泡排序
冒泡排序
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));
}
}
边栏推荐
- Selection (028) - what is the output of the following code?
- Research Report on market evaluation and investment direction of Chinese dermatology drugs (2022 Edition)
- Research Report on solar battery charger industry - market status analysis and development prospect forecast
- Laravel pagoda security configuration
- 【武汉大学】考研初试复试资料分享
- 非单文件组件
- 03_SpingBoot 核心配置文件
- Gocolly manual
- Financial management [6]
- Dynamic menu, auto align
猜你喜欢
![[ROS play with turtle turtle]](/img/94/4d1063f063d115aeef5cdf099278f8.png)
[ROS play with turtle turtle]

【js】-【链表-应用】-学习笔记

02_ Springboot starter case

2022 simulated 100 questions and simulated examination of high-altitude installation, maintenance and demolition

Simulated 100 questions and online simulated examination of high voltage electrician examination in 2022

Non single file component

【js】-【数组、栈、队列、链表基础】-笔记

Epics record reference 4 -- fields for all input records and fields for all output records

Canvas to add watermark to pictures

Tech talk activity review kubernetes skills of cloud native Devops
随机推荐
docker-mysql8-主从
laravel 创建 service层
Blogs personal blog project details (servlet implementation)
非单文件组件
laravel 添加helper文件
03_SpingBoot 核心配置文件
[laravel series 7.9] test
laravel 消息队列
02_ Springboot starter case
Selection (028) - what is the output of the following code?
Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis
[ROS play with turtle turtle]
laravel 定时任务
案例解析:用「度量」提升企业研发效能|ONES Talk
慕思股份深交所上市:靠床垫和“洋老头”走红 市值224亿
vulnhub DC: 2
[text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
Push markdown format information to the nailing robot
The extra points and sharp tools are worthy of the trust | know that Chuangyu won the letter of thanks from the defense side of the attack and defense drill!
Laravel scheduled task