Advertisement
Guest User

3.4

a guest
Oct 15th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HelloApp
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random number = new Random();
  10.             int[] array = new int[30];
  11.  
  12.             for (int i = 0; i < 30; i++)
  13.             {
  14.                 array[i] = number.Next(1, 100);
  15.             }
  16.  
  17.             if (array[0] > array[1])
  18.             {
  19.                 Console.ForegroundColor = ConsoleColor.Red;
  20.                 Console.Write(array[0] + " ");
  21.                 Console.ForegroundColor = ConsoleColor.White;
  22.             }
  23.             else
  24.             {
  25.                 Console.Write(array[0] + " ");
  26.             }
  27.             for (int i = 1; i < 29; i++)
  28.             {
  29.                 if (array[i] > array[i - 1] && array[i] > array[i + 1])
  30.                 {
  31.                     Console.ForegroundColor = ConsoleColor.Red;
  32.                     Console.Write(array[i] + " ");
  33.                     Console.ForegroundColor = ConsoleColor.White;
  34.                 }
  35.                 else
  36.                 {
  37.                     Console.Write(array[i] + " ");
  38.                 }
  39.             }
  40.             if (array[array.Length-1] > array[array.Length-2])
  41.             {
  42.                 Console.ForegroundColor = ConsoleColor.Red;
  43.                 Console.Write(array[array.Length - 1] + " ");
  44.                 Console.ForegroundColor = ConsoleColor.White;
  45.             }
  46.             else
  47.             {
  48.                 Console.Write(array[array.Length - 1] + " ");
  49.             }
  50.             Console.WriteLine();
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement