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 ArrayModifier
- {
- class ArrayModifier
- {
- static void Main()
- {
- long[] arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
- while (true)
- {
- string[] command = Console.ReadLine().Split(' ');
- if(command[0] == "end")
- {
- break;
- }
- else if(command[0] == "swap")
- {
- int index1 = int.Parse(command[1]);
- int index2 = int.Parse(command[2]);
- int oldValue = arr[index1];
- arr[index1] = arr[index2];
- arr[index2] = oldValue;
- }
- else if(command[0] == "multiply")
- {
- int index1 = int.Parse(command[1]);
- int index2 = int.Parse(command[2]);
- arr[index1] = arr[index1] * arr[index2];
- }
- else if(command[0] == "decrease")
- {
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i]--;
- }
- }
- }
- Console.WriteLine(string.Join(", ",arr));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment