我的排序代码没有给出正确的结果它没有正确排序给定的列表,而我没有收到错误请检查它,
static void Main(string[] args)
{
List<int> a = new List<int>(new int[] { 3, 7, 6, 1, 8, 5 });
int temp;
// foreach(int i in a)
for(int i=1; i<=a.Count; i++)
for(int j=0; j<a.Count-i; j++)
if (a[j] > a[j + 1])
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
Console.WriteLine(a[j]);
}
Console.Read();
}