Professional Documents
Culture Documents
Algorithm 演算法
Algorithm 演算法
Algorithm 5 InsertionSort(A, n)
Input: 具有 n 個整數的陣列 A
Algorithm 3 PrimeCheck2(n) Output: 陣列 A(其中的整數已依其數值由小到大排列)
Input: 一個大於 2 的正整數 n 1. for i = 1 to n-1 do
2. j←i–1
3. temp ← A[i]
4. while (t < A[j] & j >= 0) do
5. A[j+1] ← A[j]
6. j←j–1
7. end while
8. A[j+1] ← temp
9. end for
10. return A