Garloon

3.5

Aug 29th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 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 _3._3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = new int[30];
  14.             Random random = new Random();
  15.  
  16.             Console.Write("Массив: ");
  17.             for (int i = 0; i < array.Length; i++)
  18.             {
  19.                 array[i] = random.Next(1, 100);
  20.                 Console.Write(array[i] + " ");
  21.             }
  22.             Console.WriteLine();
  23.             Console.Write("\nЛокальные максимумы данного массива: ");
  24.  
  25.             if (array.First() > array.First() + 1)
  26.             {
  27.                 Console.Write(array.First() + " ");
  28.             }
  29.             for (int j = 1; j < array.Length - 1; j++)
  30.             {
  31.                 if (array[j - 1] < array[j] && array[j + 1] < array[j])
  32.                 {
  33.                     Console.Write(array[j] + " ");
  34.                 }
  35.             }
  36.             if (array.Last() > array.Last() - 1)
  37.             {
  38.                 Console.Write(array.Last());
  39.             }
  40.             Console.WriteLine();
  41.             Console.ReadKey();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment