MaxProductOfThree

 1         /// <summary>
 2         /// Solution
 3         /// 100/100
 4         /// </summary>
 5         /// <param name="A"></param>
 6         /// <returns></returns>
 7         public int solution(int[] A)
 8         {
 9             int result = 0;
10             int temp=0;
11             Array.Sort(A);
12             //1
13             result = A[A.Length - 1] * A[A.Length - 2] * A[A.Length - 3];
14             //2
15             temp = A[A.Length - 1] * A[0] * A[1];
16             result = temp > result ? temp : result;
17             //3
18             temp = A[A.Length - 1] * A[A.Length - 2] * A[0];
19             result = temp > result ? temp : result;
20             return result;
21         }

 

posted @ 2015-07-25 11:36  叫我霍啊啊啊  阅读(159)  评论(0编辑  收藏  举报