Advertisement
Guest User

Untitled

a guest
May 14th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace _04largerThanNeighbour
  5. {
  6. class Larger
  7. {
  8.  
  9. static int LargerThanNeighbour(int [] array)
  10. {
  11. int elements = 0;
  12. for (int i = 0; i < array.Length - 1; i++)
  13. {
  14.  
  15. if (array[i] > array[i + 1]&&array[i]>array[i-1])
  16. {
  17. elements++;
  18. }
  19.  
  20.  
  21.  
  22. }
  23. return elements;
  24. }
  25. static void Main()
  26. {
  27. int size = int.Parse(Console.ReadLine());
  28. var line = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  29. int [] array = new int [size];
  30. for (int i = 0; i < size; i++)
  31. {
  32. array[i] = int.Parse(line[i]);
  33. }
  34. Console.WriteLine(LargerThanNeighbour(array));
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement