using System; using System.Collections.Generic; using System.Text.RegularExpressions; class Program { static string InputPattern = "Input4"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("5+3"); //2 } else if (InputPattern == "Input2") { WillReturn.Add("10-20"); //30 } else if (InputPattern == "Input3") { WillReturn.Add("-2+-3"); //1 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); Match InsMatch = Regex.Match(InputList[0], @"([-+]?[0-9]+)([-+])([-+]?[0-9]+)$"); int X = int.Parse(InsMatch.Groups[1].Value); string Ope = InsMatch.Groups[2].Value; int Y = int.Parse(InsMatch.Groups[3].Value); if (Ope == "+") Console.WriteLine(X - Y); else Console.WriteLine(X + Y); } }