标签:
通过比较,将小的数字向上浮动一位,直到整个数组的数字对比完成,结果:5,7,9,22,47,52,64.
var myArray = new int[] {5,7,47,52,64,9,22};
for (var j = 1; j< myArray.Length; j++)
{
for (var i= 0; i < myArray.Length-1; i++)
{
if (myArray[i] <= myArray[i + 1]) continue;
var temp = myArray[i];
myArray[i] = myArray[i + 1];
myArray[i + 1] = temp;
}
}
标签:
原文地址:http://www.cnblogs.com/professional-NET/p/4912916.html