Advertisement
terlichki

Untitled

Jun 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 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. using System.Numerics;
  7. using System.Text.RegularExpressions;
  8.  
  9.  
  10. namespace Letters_Change_Numbers
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. string[] input =Console.ReadLine()
  17. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  18. StringBuilder partition = new StringBuilder();
  19. double finalResult = 0;
  20. for (int i = 0; i < input.Length; i++)
  21. {
  22. partition.Append(input[i]);
  23. var firstL = partition[0];
  24. var secondR = partition[partition.Length - 1];
  25. double midle = double.Parse(getMatches(input[i]));
  26. double forEachArr = getMathResult(firstL, secondR, midle);
  27. finalResult += forEachArr;
  28.  
  29. partition.Clear();
  30. }
  31. Console.WriteLine($"{finalResult:f2}");
  32.  
  33. }
  34.  
  35. static string getMatches(string n) {
  36. string patern = @"\d+";
  37. Regex regex = new Regex(patern);
  38. Match match = regex.Match(n);
  39. string midle = "";
  40. if (match.Success)
  41. {
  42. midle = match.Value;
  43. }
  44. return
  45. (midle);
  46. }
  47.  
  48. static double getMathResult(char first, char second, double midle)
  49. {
  50. double sum = 0;
  51. if (first >= 65 && first<= 90)
  52. {
  53. sum = midle / (first - 64);
  54.  
  55. }
  56. else if (first>=95 && first<=122)
  57. {
  58. sum = midle * (first - 96);
  59. }
  60. if (second >= 95 && second <= 122)
  61. {
  62. sum +=(second - 96);
  63. }
  64. if (second >= 65 && second <= 90)
  65. {
  66. sum -=(second - 64);
  67. }
  68.  
  69. return
  70. (sum);
  71. }
  72.  
  73.  
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement