Advertisement
PRO100LY4UK

3.5

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