Guest User

Untitled

a guest
Dec 9th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem_3___Nether_Realms
  8. {
  9. class Program
  10. {
  11. public static object Mathch { get; private set; }
  12.  
  13. static void Main(string[] args)
  14. {
  15. var input = Console.ReadLine().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  16.  
  17. for (int i = 0; i < input.Length; i++)
  18. {
  19. input[i] = input[i].Trim(' ');
  20. }
  21.  
  22. foreach (var currentInput in input.OrderBy(a => a))
  23. {
  24. MatchCollection miniHealth = Regex.Matches(currentInput, @"[^0-9\+\-\*\/\.]");
  25. decimal health = 0;
  26. foreach (Match item in miniHealth)
  27. {
  28. health += char.Parse(item.Value);
  29. }
  30. MatchCollection miniDamage = Regex.Matches(currentInput, @"(-)?([0-9]+)[.]?[0-9]*");
  31. decimal damage = 0;
  32. foreach (Match item in miniDamage)
  33. {
  34. damage += decimal.Parse(item.Value);
  35. }
  36. MatchCollection pois = Regex.Matches(currentInput, @"\*");
  37. var unj = pois.Count;
  38. for (int i = 0; i < unj; i++)
  39. {
  40. damage *= 2;
  41. }
  42. MatchCollection delt = Regex.Matches(currentInput, @"/");
  43. var del = delt.Count;
  44. for (int i = 0; i < del; i++)
  45. {
  46. damage /= 2;
  47. }
  48. Console.WriteLine($"{currentInput} - {health} health, {damage:f2} damage ");
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment