Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 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 Legendary_Fiarming
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. SortedDictionary<string, int> information = new SortedDictionary<string, int>() { { "shards", 0 }, { "fragments", 0 }, { "motes", 0 } };
  14. List<string> keyMaterials = new List<string>() { "shards", "fragments", "motes" };
  15. bool haveWinner = false;
  16. do
  17. {
  18. string input = Console.ReadLine().ToLower();
  19. string[] splittedInput = input.Split(' ').Where(x=> !string.IsNullOrEmpty(x)).ToArray();
  20. string[] keys = new string[splittedInput.Length / 2];
  21. int[] values = new int[splittedInput.Length / 2];
  22. for (int i = 0, m = 0; i < splittedInput.Length; i += 2, m++)
  23. {
  24. values[m] = int.Parse(splittedInput[i]);
  25. }
  26. for (int i = 1, m = 0; i < splittedInput.Length; i += 2, m++)
  27. {
  28. keys[m] = splittedInput[i];
  29. }
  30. for (int i = 0; i < keys.Length; i++)
  31. {
  32. if (information.ContainsKey(keys[i]))
  33. {
  34. information[keys[i]] += values[i];
  35. if (information[keyMaterials[0]] >= 250 || information[keyMaterials[1]] >= 250 || information[keyMaterials[2]] >= 250)
  36. {
  37. break;
  38. }
  39. }
  40. else
  41. {
  42. information[keys[i]] = values[i];
  43. }
  44. }
  45.  
  46. if (information[keyMaterials[0]] >= 250 || information[keyMaterials[1]] >= 250 || information[keyMaterials[2]] >= 250)
  47. {
  48. break;
  49. }
  50. } while (!haveWinner);
  51. string test = information.First(x => x.Value >= 250).ToString();
  52. if (test.Contains("fragments"))
  53. {
  54. Console.WriteLine("Valanyr obtained!");
  55. test = "fragments";
  56. information[test] = information[test] - 250;
  57. }
  58. else if (test.Contains("shards"))
  59. {
  60. Console.WriteLine("Shadowmourne obtained!");
  61. test = "shards";
  62. information[test] = information[test] - 250;
  63. }
  64. else
  65. {
  66. Console.WriteLine("Dragonwrath obtained!");
  67. test = "motes";
  68. information[test] = information[test] - 250;
  69. }
  70. foreach (var item in information.OrderByDescending(y => y.Value).Where(x => keyMaterials.Contains(x.Key))) //Принтират се тези, които са ключови.
  71. {
  72. Console.WriteLine($"{item.Key}: {item.Value}");
  73. }
  74. foreach (var item in information.OrderBy(y => y.Key).Where(x => !keyMaterials.Contains(x.Key))) //Принтират се останалите, по азбучен ред.
  75. {
  76. Console.WriteLine($"{item.Key}: {item.Value}");
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement