///
///
/// public static int[] Sort(int[] sort)
{
for (int i = 0; i {
int currentCount = sort[i]; //把当前循环到的数值取出来
int currentIndex = i; //把当前循环到的索引取出来
while (currentIndex > 0 && sort[currentIndex – 1] > currentCount) //索引大于0并且当前位置的前一个数值大于当前的数
{
sort[currentIndex] = sort[currentIndex – 1]; //因为是从大到小,所以与前边的一个调换位置
currentIndex–; //当前的索引减1,因为前边都已经排序所以都小于当前数,所以索引都要减1
}
sort[currentIndex] = currentCount; //
}
return sort;
}文章知识点与官方知识档案匹配,可进一步学习相关知识算法技能树首页概览35125 人正在系统学习中
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!