Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CSharpAdvanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- var numbers = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToList();
- Func<int, int> funcAdd = n => n + 1;
- Func<int, int> funcMultiply = n => n * 2;
- Func<int, int> funcSubtract = n => n - 1;
- Action<List<int>> printAction = n => Console.WriteLine(string.Join(" ", n));
- while (true)
- {
- var command = Console.ReadLine();
- if (command == "end")
- {
- break;
- }
- switch (command)
- {
- case "add":
- numbers = numbers.Select(n => funcAdd(n)).ToList();
- break;
- case "multiply":
- numbers = numbers.Select(n => funcMultiply(n)).ToList();
- break;
- case "subtract":
- numbers = numbers.Select(n => funcSubtract(n)).ToList();
- break;
- case "print":
- printAction(numbers);
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement