Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _05.AppliedArithmetics
- {
- class Program
- {
- private static int[] numbers;
- static void Main()
- {
- numbers = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToArray();
- string command = Console.ReadLine();
- Action<string> manipulateNums = operation =>
- {
- switch (operation)
- {
- case "add":
- numbers = numbers.Select(n => n + 1).ToArray();
- break;
- case "multiply":
- numbers = numbers.Select(n => n * 2).ToArray();
- break;
- case "subtract":
- numbers = numbers.Select(n => n - 1).ToArray();
- break;
- case "print":
- Console.WriteLine(string.Join(" ", numbers));
- break;
- }
- };
- while (command != "end")
- {
- manipulateNums(command);
- command = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement