C# 面试算法

从一个数组里选出最大的两个数

        static void PickupMax2(int[] digits)
        {
            if (digits.Length < 2)
            {
                throw new ArgumentOutOfRangeException();
            }

            int max1 = digits[0];
            int max2 = digits[0];

            foreach (int i in digits)
            {
                if (i > max1)
                {
                    max2 = max1;
                    max1 = i;
                }
            }

            Console.WriteLine("max1: {0}, max2: {1}", max1, max2);
        }
原文地址:https://www.cnblogs.com/lbsong/p/1678444.html