Advertisement
Guest User

Untitled

a guest
May 7th, 2015
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LargerNeighbours_3
  8. {
  9.     class LargerNeighbours_3
  10.     {
  11.         static int[] arr;
  12.  
  13.         static bool CheckIfGreater(int idx)
  14.         {
  15.             bool isGreater;
  16.             if (idx == 0)
  17.             {
  18.                 isGreater = arr[idx] > arr[idx + 1];
  19.             }
  20.             else if (idx == arr.Length - 1)
  21.             {
  22.                 isGreater = arr[idx] > arr[idx - 1];
  23.             }
  24.             else
  25.             {
  26.                 isGreater = arr[idx] > arr[idx - 1] && arr[idx] > arr[idx + 1];
  27.             }
  28.             return isGreater;
  29.         }
  30.         static void Main(string[] args)
  31.         {
  32.             string inputArray = Console.ReadLine();
  33.             arr = inputArray.Split().Select(int.Parse).ToArray();
  34.  
  35.             for (int i = 0; i < arr.Length; i++)
  36.             {
  37.                 Console.WriteLine(CheckIfGreater(i));
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement