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;
- using System.Numerics;
- using System.Text.RegularExpressions;
- namespace Letters_Change_Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input =Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- StringBuilder partition = new StringBuilder();
- double finalResult = 0;
- for (int i = 0; i < input.Length; i++)
- {
- partition.Append(input[i]);
- var firstL = partition[0];
- var secondR = partition[partition.Length - 1];
- double midle = double.Parse(getMatches(input[i]));
- double forEachArr = getMathResult(firstL, secondR, midle);
- finalResult += forEachArr;
- partition.Clear();
- }
- Console.WriteLine($"{finalResult:f2}");
- }
- static string getMatches(string n) {
- string patern = @"\d+";
- Regex regex = new Regex(patern);
- Match match = regex.Match(n);
- string midle = "";
- if (match.Success)
- {
- midle = match.Value;
- }
- return
- (midle);
- }
- static double getMathResult(char first, char second, double midle)
- {
- double sum = 0;
- if (first >= 65 && first<= 90)
- {
- sum = midle / (first - 64);
- }
- else if (first>=95 && first<=122)
- {
- sum = midle * (first - 96);
- }
- if (second >= 95 && second <= 122)
- {
- sum +=(second - 96);
- }
- if (second >= 65 && second <= 90)
- {
- sum -=(second - 64);
- }
- return
- (sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement