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.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace judge
- {
- class judge
- {
- static void Main(string[] args)
- {
- string pattern = @"\s+";
- List<string> numsList = Regex.Split(Console.ReadLine(), pattern).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
- double result = 0;
- for (int i = 0; i < numsList.Count; i++)
- {
- double num = double.Parse(numsList[i].Substring(1, numsList[i].Length - 2));
- int firstLetter = char.ToUpper(numsList[i][0]) - 64;
- int lastLetter = char.ToUpper(numsList[i][numsList[i].Length - 1]) - 64;
- if (char.IsUpper(numsList[i][0]))
- {
- //Console.WriteLine("{0}/{1}={2}", num, firstLetter, num/ firstLetter);
- num /= firstLetter;
- }
- else
- {
- //Console.WriteLine("{0}*{1}={2}", num, firstLetter, num * firstLetter);
- num *= firstLetter;
- }
- if (char.IsUpper(numsList[i][numsList[i].Length - 1]))
- {
- //Console.WriteLine("{0}-{1}={2}", result, lastLetter, result - lastLetter);
- num -= lastLetter;
- }
- else
- {
- //Console.WriteLine("{0}+{1}={2}", result, lastLetter, result + lastLetter);
- num += lastLetter;
- }
- result += num;
- }
- Console.WriteLine("{0:F2}", result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement