具体思路是什么?

解决方案 »

  1.   

    pre节点
    cur 节点循环中
    if cur.value > cur.Next.value 交换
    tmp = cur.Next;
    pre.Next = tmp;
    cur.Next = temp.Next;
    temp.Next = cur.Next;
    pre = pre.Next;
    else
    cur = cur.Next;
    pre = pre.Next
      

  2.   


    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication2
    {
      class Program
      {
      static void Main(string[] args)
      {
      int[] myArray = new int[] { 10, 8, 3, 5, 6, 7, 4, 6, 9 };  for (int k=0; k < 9; k++)
      Console.Write("{0},",myArray[k]);
      Console.WriteLine();
      // 取长度最长的词组 -- 冒泡法
      for (int j = 1; j < myArray.Length; j++)
      {
      for (int i = 0; i < myArray.Length - 1; i++)
      {
      // 如果 myArray[i] < myArray[i+1] ,则 myArray[i] 下沉一位
      if (myArray[i] < myArray[i + 1])
      {
      int temp = myArray[i];
      myArray[i] = myArray[i + 1];
      myArray[i + 1] = temp;
      }
      }
      }  for (int k=0; k < 9; k++)
      Console.Write("{0},", myArray[k]);
      Console.ReadKey();
      }
      }
    }