Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] slot = new int[10];
- int minSlot = 0;
- int maxSlot = -1;
- Random random = new Random();
- Console.WriteLine("строка : ");
- int indent = 1;
- for (int i = 0; i < slot.Length; i++)
- {
- slot[i] = random.Next(1, 10);
- Console.Write(slot[i] + " ");
- maxSlot++;
- }
- Console.WriteLine();
- Console.WriteLine("локальные максимумы : ");
- for (int i = 0; i < slot.Length; i++)
- {
- if (i == minSlot && slot[i] >= slot[i + indent])
- {
- Console.Write(slot[i] + " ");
- }
- else if (i == maxSlot)
- {
- if (slot[i] >= slot[i - indent])
- {
- Console.Write(slot[i] + " ");
- }
- else
- {
- continue;
- }
- }
- else if (slot[i] >= slot[i + indent] && slot[i] >= slot[i - indent])
- {
- Console.Write(slot[i] + " ");
- }
- else
- {
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment