Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 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 Rainbow_Raindrop
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var command = Console.ReadLine();
  14. var rechnik = new SortedDictionary<double, List<int>>();
  15. var colors = new List<int>();
  16. double volume = 0.0;
  17. int red = 0;
  18. int green = 0;
  19. int blue = 0;
  20.  
  21. while (command != "End")
  22. {
  23.  
  24. List<string> input = command.Split(' ').ToList();
  25.  
  26. if (input.Count > 4 || input.Count < 4)
  27. {
  28. continue;
  29. }
  30. volume = double.Parse(input[0]);
  31. red = int.Parse(input[1]);
  32. green = int.Parse(input[2]);
  33. blue = int.Parse(input[3]);
  34. bool raindDrop = false;
  35. int count = 0;
  36. int count1 = 0;
  37. //for (int i = 1; i < input.Count ; i++)
  38. //{
  39. if (red < 0 && red > 255)
  40. {
  41. red =0;
  42. }
  43. if (blue < 0 && blue > 255)
  44. {
  45. blue = 0;
  46. }
  47. if (green < 0 && green > 255)
  48. {
  49. green = 0;
  50. }
  51. //}
  52. for (int i = 1; i < input.Count; i++)
  53. {
  54. if (int.Parse(input[i]) > 200)
  55. {
  56. count++;
  57. }
  58. if (int.Parse(input[i]) < 100)
  59. {
  60. count1++;
  61. }
  62. }
  63. if (count == 1 && count1 == 2)
  64. {
  65. raindDrop = true;
  66.  
  67. for (int i = 1; i < input.Count; i++)
  68. {
  69. colors.Add(int.Parse(input[i]));
  70. }
  71. if (!rechnik.ContainsKey(volume))
  72. {
  73. rechnik.Add(volume, colors);
  74. }
  75.  
  76. }
  77. command = Console.ReadLine();
  78.  
  79. }
  80.  
  81.  
  82. int counter = 1;
  83. Console.WriteLine($"Rainbow Raindrops: {rechnik.Count}");
  84. foreach (var key in rechnik.Keys)
  85. {
  86. Console.WriteLine($"{counter}. V:{key:f2} -> R:{rechnik[key][0]} G:{rechnik[key][1]} B:{rechnik[key][2]}");
  87. counter++;
  88.  
  89. }
  90.  
  91.  
  92. }
  93.  
  94.  
  95.  
  96.  
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement