标签:
#include <iostream> using namespace std; /** \ Insert Sort * * Key: * * reserve: tm = a[i] * * position: int j = i-1 * * move : while * */ template <typename T> void insertSort(T a[], int n) { T tm; for (int i = 1; i < n; i++) { tm = a[i]; int j = i-1; while (a[j] > tm && j >= 0){ a[j+1] = a[j]; j--; } a[j+1]=tm; } }
标签:
原文地址:http://www.cnblogs.com/lifeinsmile/p/5205668.html