Advertisement
Guest User

Ivan

a guest
Jan 23rd, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 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 ArrayLocalMax
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = { 9, 5, 4, 3, 4, 5, 3, 4, 5, 4, 5, 4, 3, 7, 8, 9, 7, 6, 7, 6, 4, 6, 4, 5, 3, 5, 3, 5, 3, 5 };
  14.  
  15.             for (int i = 1; i < array.Length - 1; i++)
  16.             {
  17.                 if(array[i]>array[i-1]&& array[i] > array[i + 1])
  18.                 {
  19.                     Console.Write(array[i] + " ");
  20.                 }
  21.             }
  22.  
  23.  
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement