C#编程实现一个冒泡排序算法

来源:百度知道 编辑:UC知道 时间:2024/06/06 20:55:56
如题

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

namespace test11
{
class Program
{
const int N = 10;

static void Main(string[] args)
{
int[] a=new int[N];

for (int i = 0; i < N; i++)
a[i] =Convert.ToInt32( Console.ReadLine());

for(int i=0;i<N-1;i++)
for (int j = N - 2; j >= i; j--)
{
if (a[j+1] < a[j])
{
int t;
t = a[j+1];
a[j+1] = a[j];
a[j] = t;

}

}
for (int i = 0; i < N; i++)
Console.WriteLine("{0}", a[i]);

}
}
}

public int[] maoPao(int[] list)//冒泡排序
{