Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleTesting2
- {
- class ConsoleTesting2
- {
- static void Main()
- {
- int[] test = new int[10];
- for (int i = 0; i < 10; i++)
- {
- Console.Write("Index {0}: ", i);
- test[i] = int.Parse(Console.ReadLine());
- }
- Console.WriteLine();
- char answer = 'n';
- do
- {
- Console.Write("Enter index to check: ");
- Console.WriteLine("Greater: {0}", GreaterThanNeighbours(int.Parse(Console.ReadLine()), test));
- Console.Write("Check another? (y/n): ");
- answer = char.Parse(Console.ReadLine());
- } while (answer == 'y');
- }
- private static bool GreaterThanNeighbours(int index, params int[] array)
- {
- bool isGreater = array[index] > array[index + 1] && array[index] > array[index - 1];
- return isGreater;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment