master
Omooo 6 years ago
parent b86cb036e6
commit 1683408505
  1. 3
      README.md
  2. 80
      blogs/Algorithm/八大排序.md
  3. 2
      blogs/Android/自定义 View.md

@ -22,6 +22,7 @@ Android Notes
2. [RecyclerView](https://github.com/Omooo/Android-Notes/blob/master/blogs/Android/RecyclerView.md)
3. [ViewPager](https://github.com/Omooo/Android-Notes/blob/master/blogs/Android/ViewPager.md)
4. [ConstraintLayout](https://github.com/Omooo/Android-Notes/blob/master/blogs/Android/ConstraintLayout.md)
5. [自定义 View](https://github.com/Omooo/Android-Notes/blob/master/blogs/Android/%E8%87%AA%E5%AE%9A%E4%B9%89%20View.md)
##### 其他
@ -93,6 +94,8 @@ Android Notes
[一篇文章搞定 HashMap](https://github.com/Omooo/Android-Notes/blob/master/blogs/Algorithm/HashMap.md)
[八大排序]()
#### 计算机网络
[Http 和 Https](https://github.com/Omooo/Android-Notes/blob/master/blogs/computer_network/Http%20%E4%B8%8E%20Https.md)

@ -0,0 +1,80 @@
---
八大排序
---
#### 前言
八大排序:
1. 冒泡排序
2. 插入排序
3. 选择排序
4. 快速排序
5. 堆排序
#### 冒泡排序
```java
private static void sort(int[] data) {
//排序
for (int i = 0; i < data.length - 1; i++) {
boolean isSorted = true;
for (int j = 0; j < data.length-1-i; j++) {
if (data[j+1] < data[j]) {
int temp = data[j+1];
data[j+1] = data[j];
data[j] = temp;
isSorted = false;
}
}
if (isSorted) break;
}
//输出
for (int i = 0; i < data.length; i++) {
System.out.println(data[i]);
}
}
```
#### 插入排序
```java
private static void sort(int[] data) {
//排序
for (int i = 1; i < data.length; i++) {
for (int j = i; (j > 0) && (data[j - 1] > data[j]); j--) {
int temp = data[j];
data[j] = data[j - 1];
data[j - 1] = temp;
}
}
//输出
for (int i = 0; i < data.length; i++) {
System.out.println(data[i]);
}
}
```
#### 选择排序
```java
private static void sort(int[] data) {
//排序
for (int i = 0; i < data.length - 1; i++) {
for (int j = i + 1; j < data.length; j++) {
if (data[i] > data[j]) {
int temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
}
//输出
for (int i = 0; i < data.length; i++) {
System.out.println(data[i]);
}
}
```
#### 快速排序

@ -360,6 +360,8 @@ GestureDetector 可以使用 MotionEvents 检测各种手势和事件,使用
#### 实战
![](https://camo.githubusercontent.com/8d4de2d0ee4b42d27424f490dc54e4e1ecb851ff/68747470733a2f2f692e6c6f6c692e6e65742f323031382f30322f30342f356137363962326435323837372e676966)
```java
public class MyProgressView extends View {

Loading…
Cancel
Save