kwest87

Untitled

Mar 29th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp2
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int[] slot = new int[30];
  15.             int minSlot = 0;
  16.             int maxSlot = -1;
  17.             Random random = new Random();
  18.             Console.WriteLine("строка : ");
  19.             int indent = 1;
  20.  
  21.             for (int i = 0; i < slot.Length; i++)
  22.             {
  23.                 slot[i] = random.Next(1, 10);
  24.                 Console.Write(slot[i] + " ");
  25.                 maxSlot++;
  26.             }
  27.             Console.WriteLine();
  28.             Console.WriteLine("локальные максимумы : ");
  29.  
  30.             for (int i = 0; i < slot.Length; i++)
  31.             {
  32.                 if (i == minSlot && slot[i] >= slot[i + indent])
  33.                 {
  34.                     Console.Write(slot[i] + " ");
  35.                 }
  36.                 else if (i == maxSlot)
  37.                 {
  38.                     if (slot[i] >= slot[i - indent])
  39.                     {
  40.                         Console.Write(slot[i] + " ");
  41.                     }
  42.                 }
  43.                 else if (slot[i] >= slot[i + indent] && slot[i] >= slot[i - indent])
  44.                 {
  45.                     Console.Write(slot[i] + " ");
  46.                 }
  47.             }
  48.         }
  49.     }
  50. }
  51. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment