Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace RegEx.cs
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. var input = Console.ReadLine();
  13. var pokemons = new List<string>();
  14. var evolution = new Dictionary<string, List<string>>();
  15. var power = new Dictionary<string, List<int>>();
  16.  
  17. while (input != "wubbalubbadubdub")
  18. {
  19. string[] danni = Regex.Split(input, @" -> ");
  20. if (danni.Length > 1)
  21. {
  22. if (evolution.ContainsKey(danni[0]))
  23. {
  24. evolution[danni[0]].Add(danni[1]);
  25. power[danni[0]].Add(int.Parse(danni[2]));
  26. }
  27. else
  28. {
  29. var cPower = new List<int>();
  30. var cEvolution = new List<string>();
  31.  
  32. cEvolution.Add(danni[1]);
  33. cPower.Add(int.Parse(danni[2]));
  34.  
  35. evolution.Add(danni[0], cEvolution);
  36. power.Add(danni[0], cPower);
  37.  
  38. }
  39. }
  40. if(danni.Length==1 && evolution.ContainsKey(danni[0]))
  41. {
  42. Console.WriteLine($"# {danni[0]}");
  43. for (int i = 0; i < evolution[danni[0]].Count; i++)
  44. {
  45. Console.WriteLine($"{evolution[danni[0]][i]} <-> {power[danni[0]][i]}");
  46. }
  47. }
  48. input = Console.ReadLine();
  49. }
  50. foreach (var item in power)
  51. {
  52. for(int i = 0; i < item.Value.Count; i++)
  53. {
  54. for (int x = i+1; x < item.Value.Count; x++)
  55. {
  56. if(item.Value[i]<item.Value[x])
  57. {
  58. int num = item.Value[i];
  59. item.Value[i] = item.Value[x];
  60. item.Value[x] = num;
  61. string text = evolution[item.Key][i];
  62. evolution[item.Key][i] = evolution[item.Key][x];
  63. evolution[item.Key][x] = text;
  64. }
  65. }
  66. }
  67. }
  68. foreach (var x in evolution)
  69. {
  70. Console.WriteLine($"# {x.Key}");
  71. for (int i = 0; i < x.Value.Count; i++)
  72. {
  73. Console.WriteLine($"{evolution[x.Key][i]} <-> {power[x.Key][i]}");
  74. }
  75. }
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement