Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- class LettersChangeNumbers
- {
- static void Main()
- {
- string input = Console.ReadLine();
- string[] text = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- List<string> textList = new List<string>();
- List<int> onlyNumbers = new List<int>();
- for(int i = 0; i < text.Length; i++)
- {
- textList.Add(text[i]);
- }
- string pattern = @"[0-9]+";
- Regex rgx = new Regex(pattern);
- for (int i = 0; i < textList.Count; i++)
- {
- Match mth = rgx.Match(textList[i]);
- string a = Convert.ToString(mth.Groups[0]);
- int number = int.Parse(a);
- onlyNumbers.Add(number);
- }
- double sum = 0;
- double sum1 = 0;
- for (int i = 0; i < text.Length; i++)
- {
- if (char.IsUpper(text[i][0]))
- {
- double convert = (double)Convert.ToChar(text[i][0]);
- sum1 = onlyNumbers[i] / (convert - 64.0);
- }
- else
- {
- double convert = (double)Convert.ToChar(text[i][0]);
- sum1 = onlyNumbers[i] * (convert - 96.0);
- }
- if (char.IsUpper(text[i][text[i].Length - 1]))
- {
- double convert = (double)Convert.ToChar(text[i][text[i].Length - 1]);
- sum += sum1 - (convert - 64.0);
- }
- else
- {
- double convert = (double)Convert.ToChar(text[i][text[i].Length - 1]);
- sum += sum1 + (convert - 96.0);
- }
- }
- Console.WriteLine("{0:F2}", sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement