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 arraytask3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rand = new Random();
- int[] array = new int[30];
- Console.WriteLine("Дан маccив элементов:");
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = rand.Next(0, 100);
- Console.Write(array[i] + " ");
- }
- Console.WriteLine("\n\nЛокальные максимумы массива:");
- for (int i = 0; i < array.Length; i++)
- {
- if (i == 0)
- {
- if (array[i] > array[i + 1])
- {
- Console.Write(array[i] + " ");
- }
- }
- else if (i == array.Length - 1)
- {
- if (array[i] > array[i - 1])
- {
- Console.Write(array[i] + " ");
- }
- }
- else if ((array[i] > array[i + 1]) && (array[i] > array[i - 1]))
- {
- Console.Write(array[i] + " ");
- }
- }
- Console.WriteLine("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement