当前位置:网站首页>冒泡排序
冒泡排序
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 添加helper文件
- Research Report on market evaluation and investment direction of Chinese dermatology drugs (2022 Edition)
- Selection (028) - what is the output of the following code?
- How should we measure agile R & D projects?
- 研究生宿舍大盘点!令人羡慕的研究生宿舍来了!
- China Sky Lantern market trend report, technical dynamic innovation and market forecast
- Dig deep into MySQL - resolve the non clustered index of MyISAM storage engine
- 【nvm】
- Selection (025) - what is the output of the following code?
- vulnhub DC: 2
猜你喜欢
What kind of processor architecture is ARM architecture?
Simulated 100 questions and online simulated examination of high voltage electrician examination in 2022
[text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
伪原创智能改写api百度-收录良好
JD 618 conference tablet ranking list announced that the new dark horse brand staff will compete for the top three, learning from Huawei, the leader of domestic products
EPICS记录参考2--EPICS过程数据库概念
RT-thread使用rt-kprintf
A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail
Detailed explanation of online group chat and dating platform project (servlet implementation)
【nvm】
随机推荐
Recommended movies: Northeast tiger, licorice pizza
Getting started with the go Cobra command line tool
監聽 Markdown 文件並熱更新 Next.js 頁面
Building Survey [3]
laravel 宝塔安全配置
QT to place the form in the lower right corner of the desktop
What kind of processor architecture is ARM architecture?
EPICS記錄參考3 -- 所有記錄都有的字段
. Net 7 Preview 1 has been officially released
How to submit the shopee opening and settlement flow?
Dig deep into MySQL - resolve the difference between clustered and non clustered indexes
China smallpox vaccine market trend report, technical innovation and market forecast
Research and investment strategy report on China's nano silver wire conductive film industry (2022 Edition)
Financial management [6]
Some updates about a hand slider (6-18, JS reverse)
【基础知识】~ 半加器 & 全加器
Pousser l'information au format markdown vers le robot nail
【js】-【字符串-应用】- 学习笔记
laravel 定时任务
推送Markdown格式信息到钉钉机器人