冒泡排序


int[] shuzu = new int[10] {1,5,2,3,4,8,9,6,7,10 };
for (int i = 0; i < shuzu.Length;i++ )
{
for (int j = i; j<shuzu.Length-1;j++ )
{
if(shuzu[i]<shuzu[j+1])
{
int zhong =shuzu[i];
shuzu[i] = shuzu[j + 1];
shuzu[j + 1] = zhong;

}

}
}
foreach (int a in shuzu)
{
Console.WriteLine(a);
}

原文地址:https://www.cnblogs.com/zzc134680/p/5411857.html