Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp95
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<long> numbers = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToList();
- string[] commands = Console.ReadLine().Split(' ');
- while (commands[0] != "end")
- {
- if (commands[0] == "swap")
- {
- long indexOne = long.Parse(commands[1]);
- long indexTwo = long.Parse(commands[2]);
- long temp = numbers[(int)indexOne];
- numbers[(int)indexOne] = numbers[(int)indexTwo];
- numbers[(int)indexTwo] = temp;
- }
- else if (commands[0] == "multiply")
- {
- long indexOne = long.Parse(commands[1]);
- long indexTwo = long.Parse(commands[2]);
- long sum = numbers[(int)indexOne] * numbers[(int)indexTwo];
- numbers[(int)indexOne] = sum;
- }
- else if(commands[0] == "decrease")
- {
- for (long i = 0; i < numbers.Count; i++)
- {
- numbers[(int)i]--;
- }
- }
- commands = Console.ReadLine().Split(' ');
- }
- Console.WriteLine(string.Join(", ", numbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement