当前位置:网站首页>冒泡排序和选择排序
冒泡排序和选择排序
2022-07-20 13:20:00 【橘子ꦿ.๓】
/**
* 冒泡排序
*
*/
public static void main(String[] args) {
int[] arr = { 12, 9, 23, 77, 6, 34 };
Demo4.sort(arr);
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i]+" ");
}
}
public static void sort(int[] arr) {
for (int x = 0; x < arr.length-1; x++) {
for (int y = 0; y < arr.length-1-x; y++) {
if (arr[y] > arr[y+1]) {
int temp;
temp = arr[y];
arr[y] = arr[y+1];
arr[y+1] = temp;
}
}
}
}
/**
* 选择排序
*
*/
public static void main(String[] args) {
int[] arr = { 12, 9, 23, 77, 6, 34 };
Demo3.sort(arr);
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i]);
}
}
public static void sort(int[] arr) {
for (int x = 0; x < arr.length - 1; x++) {
for (int y = x + 1; y < arr.length; y++) {
if (arr[x] > arr[y]) {
int temp;
temp = arr[x];
arr[x] = arr[y];
arr[y] = temp;
}
}
}
}
边栏推荐
- 五.uni-app API[路由与跳转、网络请求、数据缓存]
- 4.存储NFS
- Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
- 在CANoe中通过Panel面板控制Test Module 运行(初级)
- Google 为造芯再掀“抢人大战”,英特尔 17 年老将加入
- 4. Storage NFS
- Google lance une autre bataille pour construire des noyaux, rejoignant Intel, un vétéran de 17 ans
- 从零开始学习CANoe(十八)—— Canoe的 I/O功能 (全内外网最详细)
- Adresse de téléchargement Canoe et téléchargement et activation de Can Demo 16, avec toutes les versions logicielles Canoe jointes
- CANoe仿真功能之自动化序列(Automation Sequences )
猜你喜欢
六.uniapp[闪屏页加载方式、闪屏页设置]
行业现状令人失望,工作之后我又回到UC伯克利读博了
4. Storage NFS
When business goes out to sea, you should "get your hands dirty" before inspiration appears
除了定时器,真的没法在Simulation Node 类型的CAPL节点中实现延时了吗?
2.rsync
在CANoe中通过Panel面板控制Test Module 运行(初级)
Interprocess communication - shared memory shmat
从零开始C语言精讲篇1:初识C语言
业务出海,灵感乍现前要先「把手弄脏」
随机推荐
Double shutter Technology
限制input框中的输入类型及长度
ProSci 抗CD22抗体Epratuzum28流式细胞术展示
Android kotlin uses arouter componentized routing and datastore to save data instead of SharedPreferences
CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
四.uni-app组件[视图组件、基本内容(官方自带例如表单类)、UI组件库、组件库的坑]
Automation sequences of canoe simulation functions
2.rsync
Setting of XML parameter types in mybats
MATLAB basic grammar (I)
Arrow 之 builder
Laravel realizes bidirectional synchronization of database and migrated files
Repeaters, hubs, bridges, switches, routers
Active Data Guard 备用数据库可以运行查询操作或只读应用程序吗?
[upload range 17-21] secondary rendering, conditional competition, black and white list bypass
编程语言之父们退休太无聊,纷纷选择重返职场
HJ17 坐标移动
Yu Meimei, Ji Gongdu
芯片卖到沙子价:雷军的梦想,让这家公司「糟蹋了」
JS模板编译如何实现