Advertisement
dmitryEfremov

Untitled

Apr 14th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 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[5];
  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.    
  20.             if (array[0] >= array[1])
  21.             {
  22.                 Console.Write(array[0] + " ");
  23.             }
  24.             for (int i = 1; i <= array.Length - 2; i++)
  25.             {              
  26.                 if (array[i] >= array[i - 1] && array[i] >= array[i + 1])
  27.                 {
  28.                     Console.Write(array[i]+ " ");
  29.                 }
  30.  
  31.             }
  32.             if (array[array.Length - 1] >= array[array.Length-2])
  33.             {
  34.                 Console.Write(array[array.Length - 1] + " ");
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement