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 Les3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Локальный максимум массива: ");
- int[] arr = { 7, 2, 4, 5, 8, 2, 5, 1, 2, 4, 9, 5, 0, 2, 3, 6, 4, 7, 2, 1, 6, 2, 8, 3, 4, 7, 8, 2, 4, 5 };
- for (int i = 0; i < arr.Length; i++)
- {
- if (i == 0 && arr[i + 1] < arr[i])
- Console.Write(arr[i] + " ");
- if(i == arr.Length - 1)
- if (arr[i - 1] < arr[i])
- Console.Write(arr[i] + " ");
- if (i != 0 && i != 29)
- if (arr[i - 1] < arr[i] && arr[i + 1] < arr[i])
- Console.Write(arr[i] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement