kwest87

Untitled

Mar 29th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 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.             Random random = new Random();
  16.             Console.WriteLine("строка : ");
  17.             int indent = 1;
  18.  
  19.             for (int i = 0; i < slot.Length; i++)
  20.             {
  21.                 slot[i] = random.Next(1, 10);
  22.                 Console.Write(slot[i] + " ");
  23.             }
  24.             Console.WriteLine();
  25.             Console.WriteLine("локальные максимумы : ");
  26.  
  27.             for (int i = 0; i < slot.Length; i++)
  28.             {
  29.                 if (i == 0 && slot[i] >= slot[i + indent])
  30.                 {
  31.                     Console.Write(slot[i] + " ");
  32.                 }
  33.                 else if (i == -1)
  34.                 {
  35.                     if (slot[i] >= slot[i - indent])
  36.                     {
  37.                         Console.Write(slot[i] + " ");
  38.                     }
  39.                 }
  40.                 else if (slot[i] >= slot[i + indent] && slot[i] >= slot[i - indent])
  41.                 {
  42.                     Console.Write(slot[i] + " ");
  43.                 }
  44.             }
  45.         }
  46.     }
  47. }
  48. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment