Advertisement
pol9na

Untitled

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