Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void BiggerThanNeighbors(int[] array, int element)
- {
- if (element == 0 | element == array.Length - 1)
- {
- Console.WriteLine("Incorrect Position (first or last position) !");
- return;
- }
- if (array[element] > array[element + 1] && array[element] > array[element - 1])
- {
- Console.WriteLine("Yes! {0} < {1} > {2}", array[element - 1], array[element], array[element + 1]);
- }
- else
- {
- Console.WriteLine("Nope.");
- }
- }
- static void Main()
- {
- int[] array = { 3, 2, 5, -4, 3, 0, 1, 9, 2 };
- Console.Write("Chose a position: ");
- int position = int.Parse(Console.ReadLine());
- BiggerThanNeighbors(array, position);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment