Advertisement
dmitryEfremov

Untitled

Apr 14th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. namespace ConsoleApp5
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int[] array = new int[30];
  9.             Console.WriteLine("Заполните массив:");
  10.             for (int i = 0; i < array.Length; i++)
  11.             {              
  12.                     array[i] = Convert.ToInt32(Console.ReadLine());            
  13.             }
  14.             Console.WriteLine("Вы заполнили массив:");
  15.             for (int i = 0; i < array.Length; i++)
  16.             {
  17.                 Console.WriteLine(array[i]+" ");
  18.             }
  19.             if (array[0] > array[1])
  20.             {
  21.                 Console.Write(array[0] + " ");
  22.             }
  23.             for (int i = 1; i < array.Length - 1; i++)
  24.             {              
  25.                 if (array[i] > array[i - 1] && array[i] > array[i + 1])
  26.                 {
  27.                     Console.Write(array[i]+ " ");
  28.                 }
  29.             }
  30.             if (array[array.Length - 1] > array[array.Length-2])
  31.             {
  32.                 Console.Write(array[array.Length] + " ");
  33.             }
  34.         }    
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement