Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _3._3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[30];
- Random random = new Random();
- Console.Write("Массив: ");
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(1, 100);
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- Console.Write("\nЛокальные максимумы данного массива: ");
- if (array.First() > array.First() + 1)
- {
- Console.Write(array.First() + " ");
- }
- for (int j = 1; j < array.Length - 1; j++)
- {
- if (array[j - 1] < array[j] && array[j + 1] < array[j])
- {
- Console.Write(array[j] + " ");
- }
- }
- if (array.Last() > array.Last() - 1)
- {
- Console.Write(array.Last());
- }
- Console.WriteLine();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment