Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 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 _01.Wardrobe
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int number = int.Parse(Console.ReadLine());
  14. var wardrobe = new Dictionary<string, Dictionary<string, int>>();
  15. //int counter = 1;
  16.  
  17. for (int i = 0; i < number; i++)
  18. {
  19. string[] inputLineColor = Console.ReadLine().Split(new string[] { " -> " },
  20. StringSplitOptions.RemoveEmptyEntries).ToArray();
  21. string color = inputLineColor[0];
  22.  
  23. if (! wardrobe.ContainsKey(color))
  24. {
  25. wardrobe[color] = new Dictionary<string, int>();
  26. }
  27.  
  28. string clothes = inputLineColor[1];
  29. string[] inputClotes = clothes.Split(new char[] { ',' },
  30. StringSplitOptions.RemoveEmptyEntries).ToArray();
  31.  
  32. foreach (var item in inputClotes)
  33. {
  34. if (! wardrobe[color].ContainsKey(item))
  35. {
  36. wardrobe[color].Add(item, 0);
  37. }
  38.  
  39. wardrobe[color][item]++;
  40. }
  41.  
  42. //for (int j = 0; j < inputClotes.Length; j++)
  43. //{
  44. // if (! wardrobe[color].ContainsKey(inputClotes[j]))
  45. // {
  46. // counter = 1;
  47. // wardrobe[color][inputClotes[j]] = counter;
  48. // }
  49.  
  50. // else
  51. // {
  52. // counter++;
  53. // wardrobe[color][inputClotes[j]] = counter;
  54. // }
  55. //}
  56. }
  57.  
  58. string[] inputFinal = Console.ReadLine().Split(new[] { ' ' },
  59. StringSplitOptions.RemoveEmptyEntries).ToArray();
  60.  
  61. foreach (var kvpColor in wardrobe)
  62. {
  63. Console.WriteLine($"{kvpColor.Key} clothes:");
  64.  
  65. foreach (var kvpClothes in kvpColor.Value)
  66. {
  67. if (kvpColor.Key == inputFinal[0] && kvpClothes.Key == inputFinal[1])
  68. {
  69. Console.WriteLine($"* {kvpClothes.Key} - {kvpClothes.Value} (found!)");
  70. }
  71.  
  72. else
  73. {
  74. Console.WriteLine($"* {kvpClothes.Key} - {kvpClothes.Value}");
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement