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