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;
- namespace LettersChangeNumb
- {
- class LettersChangeN
- {
- public static decimal IterationthroughWords(char[] currentword)
- {
- decimal currentOperationsFirst = 0;
- for (int i = 0; i < currentword.Length; i++)
- {
- char beforeLetter = currentword.First();
- char afterLetter = currentword.Last();
- decimal number = ParseStringToInt(currentword);
- if (char.IsUpper(beforeLetter)) // Before -> Upper -> Divide
- {
- decimal beforeLetterPosition = LowerOrUpperCasePositioning(beforeLetter); //Позиция на 1-а буква в азбуката,при главна буква
- currentOperationsFirst = number / beforeLetterPosition;
- number = currentOperationsFirst;
- }
- else if (char.IsLower(beforeLetter)) // Before -> Lower -> Multiply
- {
- decimal beforePosition = LowerOrUpperCasePositioning(beforeLetter); //Позиция на 1-а буква в азбуката,при малка буква
- currentOperationsFirst = number * beforePosition;
- number = currentOperationsFirst;
- }
- if (char.IsUpper(afterLetter)) // After -> Upper -> Substract
- {
- decimal afterPosition = LowerOrUpperCasePositioning(afterLetter); //Позиция на 2-а буква в азбуката,при главна буква
- currentOperationsFirst = number - afterPosition;
- number = currentOperationsFirst;
- }
- else if (char.IsLower(afterLetter)) // After -> Lower -> Add
- {
- decimal afterPostion = LowerOrUpperCasePositioning(afterLetter); //Позиция на 2-а буква в азбуката,при малка буква
- currentOperationsFirst = number + afterPostion;
- number = currentOperationsFirst;
- }
- }
- return currentOperationsFirst;
- }
- public static decimal LowerOrUpperCasePositioning(char letter)
- {
- decimal indexOfLetter = 0;
- if (char.IsLower(letter))
- {
- string alphabet = "abcdefghijklmnopqrstuvwxyz";
- indexOfLetter = (alphabet.IndexOf(letter)) + 1;
- }
- else if (char.IsUpper(letter))
- {
- string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- indexOfLetter = (alphabet.IndexOf(letter)) + 1;
- }
- return indexOfLetter;
- }
- public static decimal ParseStringToInt(char[] letters)
- {
- String s = new string(letters);
- var removeFirst = s.Remove(0, 1);
- var removeLast = removeFirst.Remove(removeFirst.Length - 1, 1);
- decimal number = decimal.Parse(removeLast);
- return number;
- }
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- decimal totalSumFirstChar = 0;
- if (input.Length >= 1 || input.Length <= 10)
- {
- for (int i = 0; i < input.Length; i++)
- {
- char[] word = input[i].ToArray();
- totalSumFirstChar += IterationthroughWords(word);
- }
- Console.WriteLine("{0:F2}", totalSumFirstChar);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement