Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSharpLight
- {
- public static class Program
- {
- public static void Main()
- {
- int[] numbers = new int[30];
- Random random = new Random();
- Console.WriteLine("Массив:");
- for(int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(0,30);
- Console.Write(numbers[i]+ " ");
- }
- Console.WriteLine("\nЛокальные максимумы:");
- if(numbers[0] > numbers[1])
- {
- Console.Write(numbers[0] + " ");
- }
- for (int j = 1; j < numbers.Length - 1 ;j++)
- {
- if (numbers[j] > numbers[j - 1] & numbers[j] > numbers[j + 1])
- {
- Console.Write(numbers[j] + " ");
- j ++;
- }
- }
- if (numbers[numbers.Length - 1] > numbers[numbers.Length -2])
- {
- Console.Write(numbers[numbers.Length - 1]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement