Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class LettersChangeNumbers
- {
- static void Main()
- {
- string[] input = Console.ReadLine().Split().ToArray();
- decimal sum = 0;
- for (int i = 0; i < input.Length; i++)
- {
- string arrElement = input[i].ToString();
- if ((arrElement[0] >= 65 && arrElement[0] <= 90) && (arrElement[arrElement.Length - 1] >= 65 && arrElement[arrElement.Length - 1] <= 90))
- {
- decimal firstUpper = arrElement[0] - 64;
- decimal lastUpper = arrElement[arrElement.Length - 1] - 64;
- string number = arrElement.Substring(1, arrElement.Length - 2);
- decimal dividend = decimal.Parse(number);
- sum = (dividend / firstUpper) - lastUpper;
- }
- if ((arrElement[0] >= 65 && arrElement[0] <= 90) && (arrElement[arrElement.Length - 1] >= 97 && arrElement[arrElement.Length - 1] <= 122))
- {
- decimal firstUpper = arrElement[0] - 64;
- decimal lastLower = arrElement[arrElement.Length - 1] - 96;
- string number = arrElement.Substring(1, arrElement.Length - 2);
- decimal dividend = decimal.Parse(number);
- sum = sum + (dividend / firstUpper) + lastLower;
- }
- if ((arrElement[0] >= 97 && arrElement[0] <= 122) && (arrElement[arrElement.Length - 1] >= 65 && arrElement[arrElement.Length - 1] <= 90))
- {
- decimal firstLower = arrElement[0] - 96;
- decimal lastUpper = arrElement[arrElement.Length - 1] - 64;
- string number = arrElement.Substring(1, arrElement.Length - 2);
- decimal dividend = decimal.Parse(number);
- sum = sum + (dividend * firstLower) - lastUpper;
- }
- if ((arrElement[0] >= 97 && arrElement[0] <= 122) && (arrElement[arrElement.Length - 1] >= 97 && arrElement[arrElement.Length - 1] <= 122))
- {
- decimal firstLower = arrElement[0] - 96;
- decimal lastLower = arrElement[arrElement.Length - 1] - 96;
- string number = arrElement.Substring(1, arrElement.Length - 2);
- decimal dividend = decimal.Parse(number);
- sum = sum + (dividend * firstLower) + lastLower;
- }
- }
- Console.WriteLine("{0:F2}",sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement