示例#1
0
        private static void Test(string[] args)
        {
            int[] whitelist = In.ReadInts(args[0]);

            Array.Sort(whitelist);

            while (!StdIn.IsEmpty)
            {
                int key = StdIn.ReadInt();
                if (Rank(key, whitelist) == -1)
                {
                    StdOut.Println(key);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Reads in a sequence of real numbers from standard input and prints
        /// out their average to standard output.
        /// </summary>
        /// <param name="args">the command-line arguments</param>
        private static void Test(string[] args)
        {
            int    count = 0;         // number input values
            double sum   = 0.0;       // sum of input values

            // read data and compute statistics
            while (!StdIn.IsEmpty)
            {
                double value = StdIn.ReadDouble();
                sum += value;
                count++;
            }

            // compute the average
            double average = sum / count;

            // print results
            StdOut.Println("Average is " + average);
        }