Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace СurrencyСonverter
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rand = new Random();
- int[] array = new int[30];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = rand.Next(0, 50);
- }
- Console.WriteLine("Исходный массив");
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- Console.WriteLine("\n\nЛокальные максимумы");
- for (int i = 1; i < array.Length - 1; i++)
- {
- if (i - 1 == 0 && array[i - 1] > array[i])
- {
- Console.Write(array[i - 1] + " ");
- }
- else if (array[i] > array[i - 1] && array[i] > array[i + 1])
- {
- Console.Write(array[i] + " ");
- }
- else if (i + 1 == array.Length - 1 && array[i] < array[array.Length - 1])
- {
- Console.Write(array[array.Length - 1] + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement