使用C#完成冒泡排序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 冒泡排序
{
class Program
{
static void Main(string[] args)
{
int[] sores = { 18, 19, 20, 45, 62, 32, 89, 75, 41, 32, 69 };

for (int i = 0; i < sores.Length-1; i++)
for (int j = 0; j<sores.Length-1; j++)
{
int team;
if (sores[j] < sores[j+1])
{
team = sores[j];
sores[j] = sores[j +1];
sores[j +1] = team;


}
}
Console.WriteLine("按顺序从小到大排列后的数组是");
for(int i=0;i<sores.Length;i++)
Console.Write(sores[i]+" ");
Console.ReadKey();
}
}
}

 

posted @ 2018-11-03 11:15  秦明科  阅读(146)  评论(0编辑  收藏  举报