Advertisement
Guest User

Untitled

a guest
Sep 28th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 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 LettersChangeNumbers
  9. {
  10. static void Main()
  11. {
  12. string[] input = Console.ReadLine().Split().ToArray();
  13. decimal sum = 0;
  14.  
  15. for (int i = 0; i < input.Length; i++)
  16. {
  17. string arrElement = input[i].ToString();
  18.  
  19. if ((arrElement[0] >= 65 && arrElement[0] <= 90) && (arrElement[arrElement.Length - 1] >= 65 && arrElement[arrElement.Length - 1] <= 90))
  20. {
  21. decimal firstUpper = arrElement[0] - 64;
  22. decimal lastUpper = arrElement[arrElement.Length - 1] - 64;
  23. string number = arrElement.Substring(1, arrElement.Length - 2);
  24.  
  25. decimal dividend = decimal.Parse(number);
  26. sum = (dividend / firstUpper) - lastUpper;
  27. }
  28.  
  29. if ((arrElement[0] >= 65 && arrElement[0] <= 90) && (arrElement[arrElement.Length - 1] >= 97 && arrElement[arrElement.Length - 1] <= 122))
  30. {
  31. decimal firstUpper = arrElement[0] - 64;
  32. decimal lastLower = arrElement[arrElement.Length - 1] - 96;
  33. string number = arrElement.Substring(1, arrElement.Length - 2);
  34.  
  35. decimal dividend = decimal.Parse(number);
  36. sum = sum + (dividend / firstUpper) + lastLower;
  37. }
  38.  
  39. if ((arrElement[0] >= 97 && arrElement[0] <= 122) && (arrElement[arrElement.Length - 1] >= 65 && arrElement[arrElement.Length - 1] <= 90))
  40. {
  41. decimal firstLower = arrElement[0] - 96;
  42. decimal lastUpper = arrElement[arrElement.Length - 1] - 64;
  43. string number = arrElement.Substring(1, arrElement.Length - 2);
  44.  
  45. decimal dividend = decimal.Parse(number);
  46. sum = sum + (dividend * firstLower) - lastUpper;
  47. }
  48.  
  49. if ((arrElement[0] >= 97 && arrElement[0] <= 122) && (arrElement[arrElement.Length - 1] >= 97 && arrElement[arrElement.Length - 1] <= 122))
  50. {
  51. decimal firstLower = arrElement[0] - 96;
  52. decimal lastLower = arrElement[arrElement.Length - 1] - 96;
  53. string number = arrElement.Substring(1, arrElement.Length - 2);
  54.  
  55. decimal dividend = decimal.Parse(number);
  56. sum = sum + (dividend * firstLower) + lastLower;
  57. }
  58. }
  59. Console.WriteLine("{0:F2}",sum);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement