public static void Mopo()
{
int[] arry = { 1 ,3,4,5,6,7,84,43};
int temp = 0;
for (int i = 0; i < arry.Length; i++)
{
for (int j = 0; j < arry.Length-1-i; j++)
{
if (arry[j]<arry[j+1])//注:当<是降序,>是升序
{
temp = arry[j];
arry[j] = arry[j + 1];
arry[j + 1] = temp;
}
}
}
for (int i = 0; i < arry.Length; i++)
{
Console.Write(arry[i]+"\t\t");
}
Console.ReadKey();
}
调用:
static void Main(string[] args)
{
Mopo();
}
效果: