Insert_sort(插入排序)

原理: 將序列分爲兩組,左端爲第一組,右端爲第二組 將第二組的第一個元素與第一組的元素比較,若遇到比它大的元素則swap 迭代進行第二步 圖解: 代碼: #include <iostream> #include <algorithm> using namespace std; void Insert_sort(int* a, int left, int right) { for (int i =
相關文章
相關標籤/搜索