Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Func<int, int, int>> operations = new Dictionary<string, Func<int, int, int>>
- {
- {"+", (x,y) => x + y }
- ,{"-", (x,y) => x - y }
- ,{"/", (x,y) => x / y }
- ,{"*", (x,y) => x * y }
- ,{"%", (x,y) => x % y }
- };
- var input = new StringReader(@"+ 7 9
- - 0 4
- * 5 6
- / 8 3
- % 5 2");
- string line = input.ReadLine();
- string result = string.Empty;
- while(line != null)
- {
- var operation = line.Split(' ');
- result += Convert.ToString(operations[operation[0]](Convert.ToInt32(operation[1]), Convert.ToInt32(operation[2]))) + "\n";
- line = input.ReadLine();
- }
- Console.Write(result);
- Console.Read();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement