冒泡排序

 

 

static void Main(string[] args)
{

int temp = 0;
int[] arrBubbleSort = new int[] { 6, 3, 5, 66, 6, 7, 7, 7 };

for (int i = 0; i < arrBubbleSort.Length; i++)
{

for (int j = i + 1; j < arrBubbleSort.Length; j++)
{
if (arrBubbleSort[j]< arrBubbleSort[i])
{
temp = arrBubbleSort[i];
arrBubbleSort[i] = arrBubbleSort[j];
arrBubbleSort[j] = temp;
}
}
}

for (int i = 0; i < arrBubbleSort.Length; i++)
{
Console.WriteLine(arrBubbleSort[i]);
}

Console.Read();

}

posted on 2017-04-05 19:52  zjone391  阅读(93)  评论(0编辑  收藏  举报