コード例 #1
0
ファイル: BinarySearch.cs プロジェクト: zzhi/Algs4Net
        public static void MainTest(string[] args)
        {
            TextInput input = new TextInput(args[0]);

            int[] whitelist = input.ReadAllInts();
            input.Close();
            // sort the array
            Array.Sort(whitelist);
            TextInput StdIn = new TextInput();

            while (!StdIn.IsEmpty)
            {
                int key = StdIn.ReadInt();
                if (BinarySearch.IndexOf(whitelist, key) == -1)
                {
                    Console.WriteLine(key);
                }
            }
        }
コード例 #2
0
ファイル: Whitelist.cs プロジェクト: zzhi/Algs4Net
        public static void MainTest(string[] args)
        {
            TextInput input = new TextInput(args[0]);

            int[] white = input.ReadAllInts();
            input.Close();

            // remove duplicates, if any, so the ctor below will not throw an exception
            white = OrderHelper.RemoveDuplicates(white);
            StaticSETofInts set = new StaticSETofInts(white);

            TextInput StdIn = new TextInput();

            // Read key, print if not in whitelist.
            while (!StdIn.IsEmpty)
            {
                int key = StdIn.ReadInt();
                if (!set.Contains(key))
                {
                    Console.WriteLine(key);
                }
            }
        }