Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Ijunior
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int minRandomNumber = 1;
- int maxRandomNumber = 10;
- int arrayCapacity = 30;
- int[] numbers = new int[arrayCapacity];
- int lastIndex = numbers.Length - 1;
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(minRandomNumber, maxRandomNumber);
- Console.Write(numbers[i] + " ");
- }
- Console.WriteLine();
- Console.Write("Локальные максимумы: ");
- if (numbers[0] > numbers[1])
- {
- Console.Write(numbers[0] + " ");
- }
- for (int i = 1; i < lastIndex; i++)
- {
- if (numbers[i] > numbers[i - 1] && numbers[i] > numbers[i + 1])
- {
- Console.Write(numbers[i] + " ");
- }
- }
- if (numbers[lastIndex] > numbers[lastIndex - 1])
- {
- Console.Write(numbers[lastIndex]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement