bullit3189

Drum Set - Lists

Jan 23rd, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02.Drum_Set
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. double savings = double.Parse(Console.ReadLine());
  12. List<int> drums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  13. List<int> copy = drums.Take(drums.Count).ToList();
  14.  
  15. string input = Console.ReadLine();
  16.  
  17. while (input != "Hit it again, Gabsy!")
  18. {
  19. int hitPower = int.Parse(input);
  20.  
  21. for (int index = 0; index < drums.Count; index++)
  22. {
  23. drums[index] -= hitPower;
  24. }
  25. for (int index = 0; index < drums.Count; index++)
  26. {
  27. if (drums[index] <= 0)
  28. {
  29. int price = copy[index] * 3;
  30. if (price > savings)
  31. {
  32. drums.RemoveAt(index);
  33. copy.RemoveAt(index);
  34. }
  35. else
  36. {
  37. savings -= price;
  38. drums[index] = copy[index];
  39. }
  40. }
  41. }
  42.  
  43. input = Console.ReadLine();
  44. }
  45.  
  46. Console.WriteLine(string.Join(" ",drums));
  47. Console.WriteLine($"Gabsy has {savings:f2}lv.");
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment