3月13上午
冒泡语句:
int[] a = new int[6] { 6, 3, 5, 8, 1, 12 };
for (int i = 0; i < 6 - 1; i++)//由小到大排序
{
for (int j = i + 1; j < 6; j++)
{
int t;
if (a[i] > a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
foreach (int x in a)//遍历数组
{
Console.WriteLine(x);
}
Console.ReadLine();