static void Main(string[] args)
{
int[] bub = new int[] { 12, 5, 6, 65, 54, 4,32,4,67,8,9,0,8,34,1,23,323, };
int temp;
for (int i = 0; i <= bub.Length; i++)
{
for (int j = i+1; j <= bub.Length-1; j++)
{
if (bub[i]>bub[j])
{
temp = bub[i];
bub[i] = bub[j];
bub[j] = temp;
}
}
for (int k = 0; k < bub.Length; k++)
{
Console.Write(bub[k]+",");
}
Console.WriteLine("第{0}趟",i);
}
Console.WriteLine("Hello World!");
}
C#冒泡排序
最新推荐文章于 2024-07-13 08:57:13 发布