這是計數排序程序
(a)c[i](<=i<=n)中存放A數組中值為i的元素個數
(b)c[i](<=i<=n)中存放A數組中小於等於i的個數
(c)B中存放排序結果B[n]已經有序
(d)算法中有個並列for循環語句算法的時間復雜度為O(n)
.上三角矩陣第一行有n個元素第i行有n(i)+個元素第一行到第i行是等腰梯形而第i行上第j個元素(即aij)是第i行上第ji+個元素故元素Aij在一維數組中的存儲位置(下標k)為
k=(n+(n(i)+))(i)/+(ji+)=(ni+)(i)/+ji+
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/23055.html