标题:大家看看我这段程序哪里错了
取消只看楼主
sdnd2000
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2008-4-10
 问题点数:0 回复次数:1 
大家看看我这段程序哪里错了
我写了个快速排序的程序,运行到sh.Sort(iArrary)这里的时候,出现No overload for method 'Sort' takes '1' arguments的提示,麻烦大家看看,我这个程序是哪儿错了,该怎样去改。谢谢!

using System;

using

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();
                sh.Sort(iArrary); //就是这里有点问题
                for (int m = 0; m < iArrary.Length; m++)
                    Console.Write("{0} ", iArrary[m]);
                Console.WriteLine();
            }
        }

    }
}
搜索更多相关主题的帖子: using int Sort System 
2008-04-19 07:26
sdnd2000
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2008-4-10
得分:0 
谢谢!
2008-04-19 11:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-209872-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.165694 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved