Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _5.EasterEggs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int sumEggs = int.Parse(Console.ReadLine());
- int redEggs = 0;
- int orangeEggs = 0;
- int blueEggs = 0;
- int greenEggs = 0;
- int maxEggsOneColor = 0;
- string colorMaxEggs = string.Empty;
- for (int i = 0; i < sumEggs; i++)
- {
- string color = Console.ReadLine();
- if (color=="red")
- {
- redEggs++;
- if (maxEggsOneColor<redEggs)
- {
- maxEggsOneColor = redEggs;
- colorMaxEggs = color;
- }
- }
- else if (color == "orange")
- {
- orangeEggs++;
- if (maxEggsOneColor < orangeEggs)
- {
- maxEggsOneColor = orangeEggs;
- colorMaxEggs = color;
- }
- }
- else if (color == "blue")
- {
- blueEggs++;
- if (maxEggsOneColor < blueEggs)
- {
- maxEggsOneColor = blueEggs;
- colorMaxEggs = color;
- }
- }
- else if (color == "green")
- {
- greenEggs++;
- if (maxEggsOneColor < greenEggs)
- {
- maxEggsOneColor = greenEggs;
- colorMaxEggs = color;
- }
- }
- }
- Console.WriteLine($"Red eggs: {redEggs}");
- Console.WriteLine($"Orange eggs: {orangeEggs}");
- Console.WriteLine($"Blue eggs: {blueEggs}");
- Console.WriteLine($"Green eggs: {greenEggs}");
- Console.WriteLine($"Max eggs: {maxEggsOneColor} -> {colorMaxEggs}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement