Advertisement
VoVfe

Untitled

Mar 29th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 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 Локальные_максимумы
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = new int[30];
  14.             Random rand = new Random();
  15.            
  16.             for (int j = 0; j < array.Length; j++)
  17.             {
  18.                 array[j] = rand.Next(0, 9);
  19.                 Console.Write(array[j] + " ");
  20.             }
  21.             for (int i = 1; i < array.Length - 1; i++)
  22.             {
  23.                 int maxValue = int.MinValue;
  24.                 if (array[i] > array[i - 1] && array[i] > array[i + 1])
  25.                 {
  26.                     if (maxValue < array[i])
  27.                     {
  28.                         maxValue = array[i];
  29.                     }
  30.                     Console.Write($"\n максимальный элемент <{maxValue}>");
  31.                 }
  32.             }
  33.             Console.ReadKey();
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement