Advertisement
CrewLab

day 03_5

May 19th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 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 Les3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Локальный максимум массива: ");
  14.             int[] arr = { 7, 2, 4, 5, 8, 2, 5, 1, 2, 4, 9, 5, 0, 2, 3, 6, 4, 7, 2, 1, 6, 2, 8, 3, 4, 7, 8, 2, 4, 5 };
  15.             for (int i = 0; i < arr.Length; i++)
  16.             {
  17.                 if (i == 0 && arr[i + 1] < arr[i])
  18.                     Console.Write(arr[i] + " ");
  19.                 if(i == arr.Length - 1)
  20.                     if (arr[i - 1] < arr[i])
  21.                         Console.Write(arr[i] + " ");
  22.                 if (i != 0 && i != 29)
  23.                     if (arr[i - 1] < arr[i] && arr[i + 1] < arr[i])
  24.                         Console.Write(arr[i] + " ");
  25.             }
  26.             Console.WriteLine();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement