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 _02ArrayModifier
- {
- class ArrayModifier
- {
- static void Main(string[] args)
- {
- List<int> list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- List<string> listComand = Console.ReadLine().Split().ToList();
- while (listComand[0] != "end")
- {
- switch (listComand[0])
- {
- case "swap":
- int firstNumber = int.Parse(listComand[1]);
- int secondNumber = int.Parse(listComand[2]);
- int temp = list[firstNumber];
- list[firstNumber] = list[secondNumber];
- list[secondNumber] = temp;
- break;
- case "multiply":
- int firstNumberone = int.Parse(listComand[1]);
- int secondNumbertwo = int.Parse(listComand[2]);
- list[firstNumberone] *= list[secondNumbertwo];
- break;
- case "decrease":
- for (int decrease = 0; decrease < list.Count; decrease++)
- {
- list[decrease] --;
- }
- break;
- }
- listComand = Console.ReadLine().Split(' ').ToList();
- }
- Console.WriteLine(string.Join(", ",list));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement