class Program
{
static void Main(string[] args)
{
int[] arr = new int[] { 49, 38, 65, 97, 76, 13, 27 };
Sort(arr);
for (int i = 0; i < arr.Length; i++)
{
Console.WriteLine("得到"+arr[i]);
}
}
public static void Sort(int[] list)
{
int i, j, temp;
bool done = false;
j = 1;
while((j<list.Length)&&(!done))
{
done = true;
for (i = 0; i < list.Length - 1; i++)
{
if (list[i] > list[i + 1]) //0 1 ,1 2, 2,3 .......
{
done = false;
temp = list[i]; //替换
list[i] = list[i + 1];//替换
list[i + 1] = temp;//替换
}
}
j++; //自加
}
}