AlexRaynor

3.5 LocalMaximum

Sep 5th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication2
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[] array = new int[30];
  10.             Random rand = new Random();
  11.             for (int i = 0; i < array.Length; i++)
  12.             {
  13.                 array[i] = rand.Next(0, 100);
  14.                 Console.Write(array[i] + " ");
  15.             }
  16.  
  17.  
  18.             for (int i = 1; i < array.Length - 1; i++)
  19.             {
  20.                 if (array[i] > array[i - 1] && array[i] > array[i + 1])
  21.                 {
  22.                     Console.WriteLine("Локальный максимум " + array[i]);
  23.  
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment