Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[30];
- Random random = new Random();
- int current = 0;
- int next = 0;
- int previous = 0;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(1, 100);
- Console.WriteLine(array[i]);
- }
- int j = 0;
- do
- {
- current = array[j];
- next = array[j + 1];
- if (current > previous && current > next)
- Console.WriteLine("Найден локальный максимум " + current);
- j++;
- previous = array[j - 1];
- } while (j < 29);
- if (array[array.Length-1] > array[array.Length - 2])
- Console.WriteLine("Найден локальный максимум " + array[array.Length - 1]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement