Advertisement
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 ConsoleApp3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[30];
- Random random = new Random();
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(0, 100);
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- Console.Write("Локальные максимумы: ");
- if (array[0] > array[1])
- Console.Write(array[0] + " ");
- for (int i = 1; i < array.Length - 1; i++)
- {
- if (array[i - 1] < array[i] && array[i] > array[i + 1])
- Console.Write(array[i] + " ");
- }
- if (array[array.Length - 2] < array[array.Length - 1])
- Console.Write(array[array.Length - 1]);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement