Advertisement
Guest User

Exam 2

a guest
Jan 22nd, 2018
95
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7. namespace VII_02_Exam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             SortedDictionary<double, string> reinbowdrops = new SortedDictionary<double, string>();
  14.             while (true)
  15.             {
  16.                 string command = Console.ReadLine();
  17.                 if (command == "End") break;
  18.                 var tmp = command.Split(new char[] { ' ' },StringSplitOptions.RemoveEmptyEntries);
  19.                 if (tmp.Length == 4)
  20.                 {
  21.                     double volume = double.Parse(tmp[0]);
  22.                     int R = int.Parse(tmp[1]);
  23.                     int G = int.Parse(tmp[2]);
  24.                     int B = int.Parse(tmp[3]);
  25.                     if (R > 255 || R < 0) R = 0;
  26.                     if (G > 255 || G < 0) G = 0;
  27.                     if (B > 255 || B < 0) B = 0;
  28.                     if ((R < 100 && G < 100 && B > 200) || (R < 100 && G > 200 && B < 100) || (R > 200 && G < 100 && B < 100))
  29.                     {
  30.                         reinbowdrops.Add(volume, $" V:{volume:F2} -> R:{R} G:{G} B:{B}");
  31.                     }
  32.                 }
  33.             }
  34.             int index = 1;
  35.             Console.WriteLine($"Rainbow Raindrops: {reinbowdrops.Count}");
  36.             foreach (var drop in reinbowdrops)
  37.             {
  38.                 Console.WriteLine($"{index}.{drop.Value}");
  39.                 index++;
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement