Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _05.AppliedArithmetics
- {
- class AppliedArithmetics
- {
- static void Main()
- {
- List<int> numbers = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToList();
- Action<List<int>, string> ApplyArithmetics = (nums, opr) =>
- {
- if (opr == "add")
- {
- nums = nums.Select(n => ++n).ToList();
- }
- else if (opr == "multiply")
- {
- nums = nums.Select(n => n =n * 2).ToList();
- }
- else if (opr == "subtract")
- {
- nums = nums.Select(n => --n).ToList();
- }
- else if (opr == "print")
- {
- Console.WriteLine(string.Join(" ", nums));
- }
- };
- string command = Console.ReadLine().ToLower();
- while (command != "end")
- {
- ApplyArithmetics(numbers, command);
- command = Console.ReadLine().ToLower();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement