两个数求最大值、三个数求最大值 、n个数求最大值,求最小值同理?

两个数求最大值、三个数求最大值 、n个数求最大值,求最小值同理?

class Program

    {
        static void Main(string[] args)
        {
            //1.两个数求最大值
            Max(3,5);
            //2.三个数求最大值
            Max(3,5,9);
            //3.n个数求最大值
            Max(3,5,9,7,1,11);
        }
        public static void Max(int a,int b)
        {
            int max = a > b ? a : b;
            Console.WriteLine(max);
        }
        public static void Max(int a, int b,int c)
        {
            int max = a > b ? a : b;
            max = max > c ? max : c;
            Console.WriteLine(max);
        }
        public static void Max(params int[] a)
        {
            int max = a[0];
            for (int i = a.Length-1; i >=0; i--)
            {
                if(a[i]>max)
                {
                    max = a[i];
                }
            }
            Console.WriteLine(max);
        }
    }