Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 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.  
  8. class User_Logs
  9. {
  10. static void Main(string[] args)
  11. {
  12. string inputLine = Console.ReadLine();
  13.  
  14. string temporarily = "";
  15. long health = 0;
  16. List<double> numbers = new List<double>();
  17. int count = 0;
  18. int countDividet = 0;
  19.  
  20. string[] inputLineSplit = inputLine.Split(new char[] { ',' },StringSplitOptions.RemoveEmptyEntries).OrderBy(x => x).ToArray();
  21.  
  22. foreach (var item in inputLineSplit)
  23. {
  24. // string[] test = item.Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
  25. for (int i = 0; i < item.Length; i++)
  26. {
  27. char letters = item[i];
  28.  
  29. if (letters == '-' || letters >= '0' && letters <= '9' || letters == '.')
  30. {
  31. temporarily += letters;
  32. }
  33. else if (temporarily.Length >= 1)
  34. {
  35. numbers.Add(double.Parse(temporarily));
  36. temporarily = "";
  37. }
  38. if (letters >= 'A' && letters <= 'Z')
  39. {
  40. health += letters;
  41. }
  42. if (letters >= 'a' && letters <= 'z')
  43. {
  44. health += letters;
  45. }
  46. if (letters == '*')
  47. {
  48. count += 2;
  49. }
  50. if (letters == '/')
  51. {
  52. countDividet += 2;
  53. }
  54. }
  55. double demage = 0;
  56. for (int i = 0; i < numbers.Count; i++)
  57. {
  58. demage += numbers[i];
  59. }
  60. if (count > 1)
  61. {
  62. demage = demage * count;
  63. }
  64. if (countDividet > 1)
  65. {
  66. demage = demage / countDividet;
  67. }
  68. Console.WriteLine("{0} - {1} health, {2:F2} damage ",item,health,demage);
  69. health = 0;
  70. demage = 0;
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement