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 Локальный_максимум
- {
- class Program
- {
- static void Main(string[] args)
- {
- int kol = 0;
- int[] array = { 0, 5, 3, 4, 5 , 6, 7, 8, 9, 10 , 11, 12, 13, 14, 15 ,16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26,27,28,29,30 };
- for (int i = 0; i < array.GetLength(0); ++i)
- {
- if (i != 0 && i != array.GetLength(0)-1)
- {
- if (array[i] > array[i - 1] && array[i] > array[i + 1])
- {
- kol++;
- Console.Write(array[i] + " ");
- }
- }
- }
- if (kol > 0)
- {
- Console.WriteLine($"\nКоличество локальных максимумов = {kol}");
- }
- else { Console.WriteLine("Локальных максимумов нет ("); }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement