예제 #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);
        }