kwest87

Untitled

Mar 30th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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[10];
  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.  
  31.  
  32.             if ( slot[minSlot] >= slot[minSlot + indent])
  33.             {
  34.                 Console.WriteLine(slot[minSlot] + " ");
  35.             }
  36.  
  37.             for (int i = 0; i < slot.Length; i++)
  38.             {
  39.                 if (slot[i] >= slot[i + indent] && slot[i] >= slot[i - indent])
  40.                 {
  41.                     Console.Write(slot[i] + " ");
  42.                 }
  43.             }
  44.  
  45.             if (slot[maxSlot] >= slot[maxSlot - indent])
  46.             {
  47.                 Console.WriteLine(slot[maxSlot] + " ");
  48.             }
  49.  
  50.         }
  51.     }
  52. }
  53. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment