Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02._Array_Modifier
- {
- internal class Program
- {
- static void Main()
- {
- List<int> integerList = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToList();
- string inputComand = Console.ReadLine();
- while (inputComand != "end")
- {
- List<string> comandList = inputComand
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- if (comandList[0] == "swap")
- {
- int firstIndex = int.Parse(comandList[1]);
- int secondIndex = int.Parse(comandList[2]);
- (integerList[firstIndex], integerList[secondIndex]) = (integerList[secondIndex], integerList[firstIndex]);
- // Console.WriteLine(string.Join(" ", integerList));
- }
- else if (comandList[0] == "multiply")
- {
- int firstIndex = int.Parse(comandList[1]);
- int secondIndex = int.Parse(comandList[2]);
- integerList[firstIndex] *= integerList[secondIndex];
- // Console.WriteLine(string.Join(" ", integerList));
- }
- else if (comandList[0] == "decrease")
- {
- for (int i = 0; i < integerList.Count; i++)
- {
- integerList[i] -= 1;
- }
- }
- inputComand = Console.ReadLine();
- }
- Console.WriteLine(string.Join(", ", integerList));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement