コード例 #1
0
        /// <summary>Returns the amount of time to call <c>ThreeSum.count()</c>
        /// with <c>N</c> random 6-digit integers.</summary>
        /// <param name="N">N the number of integers</param>
        /// <returns>amount of time (in seconds) to call <c>ThreeSum.count()</c>
        ///  with <c>N</c> random 6-digit integers</returns>
        ///
        public static double TimeTrial(int N)
        {
            int[] a = new int[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = StdRandom.Uniform(-MAXIMUM_INTEGER, MAXIMUM_INTEGER);
            }
            Stopwatch timer = new Stopwatch();

            ThreeSum.Count(a);
            return(timer.ElapsedTime());
        }
コード例 #2
0
ファイル: ThreeSum.cs プロジェクト: zzhi/Algs4Net
        public static void MainTest(string[] args)
        {
            TextInput StdIn = new TextInput(args[0]);

            int[] a = StdIn.ReadAllInts();

            Stopwatch timer = new Stopwatch();
            int       cnt   = ThreeSum.Count(a);

            Console.WriteLine("Elapsed time = " + timer.ElapsedTime());
            Console.WriteLine(cnt);
        }