110,533
社区成员
发帖
与我相关
我的任务
分享
int temp;
for (int j = 0; j < list.Length-1; j++)
{
for (int i = list.Length-1; i > j; i--)
{
if (list[j] < list[i])
{
temp = list[j];
list[j] = list[i];
list[i] = temp;
}
}
}
//----------------------------------------------------------------
for (int i = 0; i < list.Length-1; i++)
{
for (int j = i + 1; j < list.Length; j++)
{
if (list[i] > list[j])
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
//-------------------------------------------------------------------------