W1thr

Массивы - 3

Feb 12th, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Homework3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = new int[30];
  14.             Random rand = new Random();
  15.  
  16.             for (int i = 0; i < array.Length; i++)
  17.             {
  18.                 array[i] = rand.Next(9, 100);
  19.                 Console.Write(array[i] + "|");
  20.             }
  21.             Console.WriteLine();
  22.  
  23.             if (array[0] > array[1])
  24.             {
  25.                 Console.WriteLine(array[0]);
  26.             }
  27.  
  28.             for (int i = 1; i < array.Length - 1; i++)
  29.             {
  30.                 if (array[i] > array[i - 1] && array[i] > array[i + 1])
  31.                 {
  32.                     Console.WriteLine(array[i]);
  33.                 }
  34.             }
  35.  
  36.             if (array[array.Length - 1] > array[array.Length - 2])
  37.             {
  38.                 Console.WriteLine(array[array.Length - 1]);
  39.             }
  40.             Console.ReadKey();
  41.         }
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment