Advertisement
DrDemonik

Untitled

Mar 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. namespace Lesson8
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int[] a = new int[30];
  9.             Random rand = new Random();
  10.             Console.WriteLine("Исходный масив");
  11.             for (int i = 0; i < a.GetLength(0); i++)
  12.             {
  13.                 a[i] = rand.Next(0,100);
  14.                 Console.Write(a[i] + " ");
  15.             }
  16.             Console.WriteLine("\nДокальные максимумы");
  17.             for (int i = 0; i < a.GetLength(0); i++)
  18.             {
  19.                 if (i == 0)
  20.                 {
  21.                     if (a[i] > a[i + 1])
  22.                         Console.Write(a[i] + " ");
  23.                 }
  24.                 else if(i== a.GetLength(0) - 1)
  25.                 {
  26.                     if (a[i] > a[i - 1])
  27.                         Console.Write(a[i] + " ");
  28.                 }
  29.                 else
  30.                 {
  31.                     if (a[i] > a[i + 1] && a[i] > a[i - 1])
  32.                         Console.Write(a[i] + " ");
  33.                 }
  34.             }
  35.  
  36.            
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement