- /**
- * 插入排序
- * */
- public class InsertSort
- {
- public void insertSort(int[] a)
- {
- int len = a.length;
- for (int i = 1; i < len; i++)
- {
- for (int j = i; j > 0; j--)
- {
- if (a[j] < a[j - 1])
- {
- int temp = a[j];
- a[j] = a[j - 1];
- a[j - 1] = temp;
- }
- else
- {
- break;
- }
- }
- }
- }
- }
插入排序
最新推荐文章于 2023-09-23 17:47:53 发布