Advertisement
dmitryEfremov

Untitled

Apr 14th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 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 - 1; 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.             int check = 1;
  37.             for (int i = 0; i < array.Length; i++)
  38.             {
  39.                for(int j = 0; j < array.Length; j++)
  40.                 {
  41.                     if (array[i] == array[j])
  42.                     {
  43.                         check = 1;
  44.                     }
  45.                     else
  46.                     {
  47.                         check = 2;
  48.                         break;
  49.                     }
  50.                 }
  51.             }
  52.             if (check == 1)
  53.             {
  54.                 Console.WriteLine("Все значения в массиве - ЛК");
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement