Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _8._LettersChangeNumbers
- {
- class LettersChangeNumbers
- {
- static void Main()
- {
- string input = Console.ReadLine();
- string[] splitedInput = input
- .Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
- double totalSum = 0;
- for (int i = 0; i < splitedInput.Length; i++)
- {
- //char firstLetter = splitedInput[i][0];
- string currentInput = splitedInput[i];
- char firstLetter = currentInput[0];
- char lastLetter = currentInput[currentInput.Length - 1];
- double digit = double.Parse(currentInput.Substring(1, currentInput.Length - 2));
- if (char.IsUpper(firstLetter))
- {
- digit /= firstLetter - 'A' + 1;
- }
- else
- {
- digit *= firstLetter - 'a' + 1;
- }
- if (char.IsUpper(lastLetter))
- {
- digit -= lastLetter - 'A' + 1;
- }
- else
- {
- digit += lastLetter - 'a' + 1;
- }
- totalSum += digit;
- }
- Console.WriteLine(totalSum.ToString("f2"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement