コード例 #1
0
        private static void MSDSort()
        {
            var fileName = "MSD.txt";
            var strings  = ReadFile(fileName);

            PrintArray(strings);
            StdOut.Println("After sorting.....");
            MSD.Sort(strings);
            PrintArray(strings);
        }
コード例 #2
0
ファイル: MSDUnitTest.cs プロジェクト: lanicon/cs-algorithms
        public void Test()
        {
            var words = "bed bug dad yes zoo now for tip ilk dim tag jot sob nob sky hut men egg few jay owl joy rap gig wee was wad fee tap tar dug jam all bad yet".Split(' ');

            MSD.Sort(words);

            for (var i = 1; i < words.Length; ++i)
            {
                Assert.True(words[i - 1].CompareTo(words[i]) <= 0);
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            string[] a = { "abv", "abd", "abc", "afr", "abt", "ayv", "bvc", "ayc" };
            var      b = a;

            //LSD.Sort(a, 3);
            MSD.Sort(b);

            int i = ForceSearch.Search1("ll", "hello");

            KMPSearch kmp = new KMPSearch("llo");

            i = kmp.Search("hello");

            Console.ReadKey();
        }
コード例 #4
0
        public void Run()
        {
            Console.WriteLine("Choose file:");   // Prompt
            Console.WriteLine("1 - shells.txt"); // Prompt
            Console.WriteLine("or quit");        // Prompt

            var fileNumber = Console.ReadLine();
            var fieName    = string.Empty;

            switch (fileNumber)
            {
            case "1":
                fieName = "shells.txt";
                break;

            case "quit":
                return;

            default:
                return;
            }

            var @in     = new In($"Files\\Strings\\{fieName}");
            var content = @in.ReadAllStrings();

            var n = content.Length;

            MSD.Sort(content);

            for (var i = 0; i < n; i++)
            {
                Console.WriteLine(content[i]);
            }

            Console.ReadLine();
        }