/*Write a method that returns the index of the first element in array that is bigger than its neighbors,
         * or -1, if there’s no such element.
         * Use the method from the previous exercise.*/

        public static int GetFirstElementBiggerThanNeighbors(int[] array)
        {
            int index = -1;

            for (int i = 0; i < array.Length; i++)
            {
                if (BiggerThanNeighbors.CheckIsBiggerThanNeighbors(array, i) != -1)
                {
                    index = i;
                    break;
                }
            }

            return(index);
        }
Exemple #2
0
    public static int FirstNumberBiggerThanNeighbors(int[] array)
    {
        int index = -1;

        for (int i = 1; i < array.Length - 1; i++)
        {
            if (BiggerThanNeighbors.IsNumberBiggerThanNeighbors(array, i))
            {
                index = i;
                break;
            }
        }

        return(index);
    }