日期:2014-05-18  浏览次数:20899 次

麻烦大家看看这段程序哪里错了呀
我写了个快速排序的程序,运行到sh.Sort(iArrary)这里的时候,出现No overload for method 'Sort' takes '1' arguments的提示,麻烦大家看看,我这个程序是哪儿错了,该怎样去改。谢谢!

using System;

using System.IO;

using System.Data;

namespace coreQuickSort
{

  public class QuickSort
  {

  private void Swap(ref int i, ref int j)
  //swap two integer 
  {
  int t;
  t = i;
  i = j;
  j = t;
  }

  public QuickSort()
  { }
  public void Sort(int[] list, int low, int high)
  {
  if (high <= low)
  {
  //only one element in array list 
  //so it do not need sort 
  return;
  }
  else if (high == low + 1)
  {
  //means two elements in array list 
  //so we just compare them 
  if (list[low] > list[high])
  {
  //exchange them 
  Swap(ref list[low], ref list[high]);
  return;
  }
  }

  //more than 3 elements in the arrary list 
  //begin QuickSort 
  myQuickSort(list, low, high);
  }

  public void myQuickSort(int[] list, int low, int high)
  {
  if (low < high)
  {
  int pivot = Partition(list, low, high);
  myQuickSort(list, low, pivot - 1);
  myQuickSort(list, pivot + 1, high);
  }
  }

  private int Partition(int[] list, int low, int high)
  {
  //get the pivot of the arrary list 
  int pivot;
  pivot = list[low];
  while (low < high)
  {
  while (low < high && list[high] >= pivot)
  {
  high--;
  }
  if (low != high)
  {
  Swap(ref list[low], ref list[high]);
  low++;
  }
  while (low < high && list[low] <= pivot)
  {
  low++;
  }
  if (low != high)
  {
  Swap(ref list[low], ref list[high]);
  high--;
  }
  }
  return low;
  }

  public class MainClass
  {
  public static void Main()
  {
  int[] iArrary = new int[] { 1, 5, 13, 6, 10, 55, 99, 2, 87, 12, 34, 75, 33, 47 };
  QuickSort sh = new QuickSort();
  [color=Red]sh.Sort(iArrary);[/color] //就是这里有点问题
  for (int m = 0; m < iArrary.Length; m++)
  Console.Write("{0} ", iArrary[m]);
  Console.WriteLine();
  }
  }

  }
}

------解决方案------------------