Advertisement
Guest User

3.4

a guest
Oct 14th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 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.             for (int i = 0; i < 30; i++)
  18.             {
  19.                 switch (i)
  20.                 {
  21.                     case 0:
  22.                         if (array[i] > array[i + 1])
  23.                         {
  24.                             Console.ForegroundColor = ConsoleColor.Red;
  25.                             Console.Write(array[i] + " ");
  26.                             Console.ForegroundColor = ConsoleColor.White;
  27.                         }
  28.                         else
  29.                         {
  30.                             Console.Write(array[i] + " ");
  31.                         }
  32.                         break;
  33.                     default:
  34.                         if (array[i] > array[i + 1] && array[i] > array[i - 1])
  35.                         {
  36.                             Console.ForegroundColor = ConsoleColor.Red;
  37.                             Console.Write(array[i] + " ");
  38.                             Console.ForegroundColor = ConsoleColor.White;
  39.                         }
  40.                         else
  41.                         {
  42.                             Console.Write(array[i] + " ");
  43.                         }
  44.                         break;
  45.                     case 29:
  46.                         if (array[i] > array[i - 1])
  47.                         {
  48.                             Console.ForegroundColor = ConsoleColor.Red;
  49.                             Console.Write(array[i] + " ");
  50.                             Console.ForegroundColor = ConsoleColor.White;
  51.                         }
  52.                         else
  53.                         {
  54.                             Console.Write(array[i] + " ");
  55.                         }
  56.                         break;
  57.                 }
  58.             }
  59.             Console.WriteLine();
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement