コード例 #1
0
        static void Main(string[] args)
        {
            int[] array1 = { 1, 2, 3, 4, 3, 2, 1 };
            int[] array2 = { 14, 21, -12, 32, -139, 67 };
            int   result = ArrayTools.FindArrayCenter(array1);

            if (result == -1)
            {
                Console.WriteLine("There is no such element in the array");
            }
            else
            {
                Console.WriteLine($"The index of the center element of array is {result}");
            }

            result = ArrayTools.FindArrayCenter(array2);
            if (result == -1)
            {
                Console.WriteLine("There is no such element in the array");
            }
            else
            {
                Console.WriteLine($"The index of the center element of array is {result}");
            }

            Console.ReadLine();
        }
コード例 #2
0
 public void FindArrayCenter_PassingNullReference_ThrowsArgumentNullException(int[] array)
 {
     Assert.Throws <ArgumentNullException>(() => ArrayTools.FindArrayCenter(array));
 }
コード例 #3
0
 public void FindArrayCenter_PassingArrayOfNumbersWithInvalidLength_ThrowsArgumentOutOfRangeException(int[] array)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => ArrayTools.FindArrayCenter(array));
 }
コード例 #4
0
 public int FindArrayCenter_PassingValidArrayOfNumbers_ExpectedPositiveTest(int[] array)
 {
     return(ArrayTools.FindArrayCenter(array));
 }