Advertisement
veselka_a

5.EasterEggs

Feb 24th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _5.EasterEggs
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int sumEggs = int.Parse(Console.ReadLine());
  14.             int redEggs = 0;
  15.             int orangeEggs = 0;
  16.             int blueEggs = 0;
  17.             int greenEggs = 0;
  18.             int maxEggsOneColor = 0;
  19.             string colorMaxEggs = string.Empty;
  20.  
  21.             for (int i = 0; i < sumEggs; i++)
  22.             {
  23.                 string color = Console.ReadLine();
  24.                
  25.  
  26.                 if (color=="red")
  27.                 {
  28.                     redEggs++;
  29.                     if (maxEggsOneColor<redEggs)
  30.                     {
  31.                         maxEggsOneColor = redEggs;
  32.                         colorMaxEggs = color;
  33.                     }
  34.                 }
  35.                 else if (color == "orange")
  36.                 {
  37.                     orangeEggs++;
  38.                     if (maxEggsOneColor < orangeEggs)
  39.                     {
  40.                         maxEggsOneColor = orangeEggs;
  41.                         colorMaxEggs = color;
  42.                     }
  43.                 }
  44.                 else if (color == "blue")
  45.                 {
  46.                     blueEggs++;
  47.                     if (maxEggsOneColor < blueEggs)
  48.                     {
  49.                         maxEggsOneColor = blueEggs;
  50.                         colorMaxEggs = color;
  51.                     }
  52.                 }
  53.                 else if (color == "green")
  54.                 {
  55.                     greenEggs++;
  56.                     if (maxEggsOneColor < greenEggs)
  57.                     {
  58.                         maxEggsOneColor = greenEggs;
  59.                         colorMaxEggs = color;
  60.                     }
  61.                 }
  62.  
  63.             }
  64.             Console.WriteLine($"Red eggs: {redEggs}");
  65.             Console.WriteLine($"Orange eggs: {orangeEggs}");
  66.             Console.WriteLine($"Blue eggs: {blueEggs}");
  67.             Console.WriteLine($"Green eggs: {greenEggs}");
  68.             Console.WriteLine($"Max eggs: {maxEggsOneColor} -> {colorMaxEggs}");
  69.  
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement