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 Rainbow_Raindrop
- {
- class Program
- {
- static void Main(string[] args)
- {
- var command = Console.ReadLine();
- var rechnik = new SortedDictionary<double, List<int>>();
- var colors = new List<int>();
- double volume = 0.0;
- int red = 0;
- int green = 0;
- int blue = 0;
- while (command != "End")
- {
- List<string> input = command.Split(' ').ToList();
- if (input.Count > 4 || input.Count < 4)
- {
- continue;
- }
- volume = double.Parse(input[0]);
- red = int.Parse(input[1]);
- green = int.Parse(input[2]);
- blue = int.Parse(input[3]);
- bool raindDrop = false;
- int count = 0;
- int count1 = 0;
- //for (int i = 1; i < input.Count ; i++)
- //{
- if (red < 0 && red > 255)
- {
- red =0;
- }
- if (blue < 0 && blue > 255)
- {
- blue = 0;
- }
- if (green < 0 && green > 255)
- {
- green = 0;
- }
- //}
- for (int i = 1; i < input.Count; i++)
- {
- if (int.Parse(input[i]) > 200)
- {
- count++;
- }
- if (int.Parse(input[i]) < 100)
- {
- count1++;
- }
- }
- if (count == 1 && count1 == 2)
- {
- raindDrop = true;
- for (int i = 1; i < input.Count; i++)
- {
- colors.Add(int.Parse(input[i]));
- }
- if (!rechnik.ContainsKey(volume))
- {
- rechnik.Add(volume, colors);
- }
- }
- command = Console.ReadLine();
- }
- int counter = 1;
- Console.WriteLine($"Rainbow Raindrops: {rechnik.Count}");
- foreach (var key in rechnik.Keys)
- {
- Console.WriteLine($"{counter}. V:{key:f2} -> R:{rechnik[key][0]} G:{rechnik[key][1]} B:{rechnik[key][2]}");
- counter++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement