Advertisement
MaoChessy

Task 17 - fix

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