Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[30];
- int minValue = 0;
- int maxValue = 9;
- Random random = new Random();
- Console.WriteLine("Сгенерированный массив:");
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(minValue, maxValue + 1);
- Console.Write(array[i] + " ");
- }
- Console.WriteLine("\nЛокальные максимумы:");
- if (array[0] > array[1])
- Console.Write(array[0] + " ");
- for (int i = 1; i < array.Length - 1; i++)
- if (array[i] > array[i - 1] && array[i] > array[i + 1])
- Console.Write(array[i] + " ");
- if (array[array.Length - 1] > array[array.Length - 2])
- Console.Write(array[0] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment