冒泡排序
int[] list = {5,3,2,8,6,9,0,1,7,4};
Console.Write("排序前");
for (int i = 0; i < list.Length; i++)
Console.Write(list[i]);
Console.WriteLine();
int tmp;
bool isOK = false;
while (!isOK)
{
isOK = true;
for (int i = 0; i < list.Length - 1; i++)
{
if (list[i] > list[i + 1])
{
tmp = list[i];
list[i] = list[i + 1];
list[i + 1] = tmp;
isOK = false;
}
}
}
Console.Write("排序后");
for (int i = 0; i < list.Length; i++)
Console.Write(list[i]);
Console.WriteLine();
Console.ReadLine();
//怎么实现从键盘读取输入数组呢。。
浙公网安备 33010602011771号