Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04largerThanNeighbour
- {
- class Larger
- {
- static int LargerThanNeighbour(int [] array)
- {
- int elements = 0;
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] > array[i + 1]&&array[i]>array[i-1])
- {
- elements++;
- }
- }
- return elements;
- }
- static void Main()
- {
- int size = int.Parse(Console.ReadLine());
- var line = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- int [] array = new int [size];
- for (int i = 0; i < size; i++)
- {
- array[i] = int.Parse(line[i]);
- }
- Console.WriteLine(LargerThanNeighbour(array));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement