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 Tasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = { 45,30, 4, 8, 15, 5, 3, 7, 9, 4, 5, 6, 7, 4, 17, 3, 5, 7, 8, 4, 3, 2, 13, 6, 6, 4, 2,7,3,21 };
- int localMax;
- Console.WriteLine("Локальные максимумы в данном массиве: ");
- if (array[0] > array[1])
- {
- localMax = array[0];
- Console.WriteLine(localMax);
- }
- for (int i = 1; i < array.Length -1; i++ )
- {
- if (array[i-1] < array[i] && array[i] > array[i+1] )
- {
- localMax = array[i];
- Console.WriteLine(localMax);
- }
- }
- if (array[array.Length -1] > array[array.Length -2])
- {
- localMax = array[array.Length - 1];
- Console.WriteLine(localMax);
- }
- Console.WriteLine("Длинна массива" + " " + array.Length + " элементов.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement