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 Maximus
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[30] { 1, 9, 2, 8, 3, 7, 4, 6, 6, 0,
- 1, 23, 56, 78, 54, 32, 83, 10, 20, 999,
- 92, 19, 33, 48, 59, 28, 43, 15, 12, 12 };
- Console.Write("Локальные максимумы: ");
- if (array[0] >= array[1]) Console.Write("{0} ", array[0]);
- for (int i = 0; i < array.Length - 2; i++)
- {
- if ((array[i + 1] >= array[i]) && (array[i + 1] >= (array[i + 2]))) Console.Write("{0} ", array[i + 1]);
- }
- if (array[array.Length - 1] >= array[array.Length - 2]) Console.Write("{0} ", array[array.Length - 1]);
- }
- }
- }
Add Comment
Please, Sign In to add comment