Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- namespace LettersChangeNumbers
- {
- class Program
- {
- static void Main()
- {
- string[] tokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
- double totalSum = 0;
- for (int i = 0; i < tokens.Length; i++)
- {
- char firstLetter = tokens[i][0];
- char secondLetter = tokens[i][^1];
- double number = int.Parse(tokens[i].Substring(1, tokens[i].Length - 2));
- _ = char.IsUpper(firstLetter) ? number /= firstLetter - 64 : number *= firstLetter - 96;
- _ = char.IsUpper(secondLetter) ? number -= secondLetter - 64 : number += secondLetter - 96;
- totalSum += number;
- }
- Console.WriteLine($"{totalSum:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement