Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace ArrayModifier
- {
- class Program
- {
- static void Main(string[] args)
- {
- var numbers = Console.ReadLine().Split(' ')
- .Select(int.Parse)
- .ToList();
- string input;
- while ((input = Console.ReadLine()) != "end")
- {
- var tokens = input.Split(' ');
- string command = tokens[0];
- if (command == "decrease")
- {
- for (int i = 0; i < numbers.Count; i++)
- {
- numbers[i]--;
- }
- }
- else
- {
- int index1 = int.Parse(tokens[1]);
- int index2 = int.Parse(tokens[2]);
- if (command == "swap")
- {
- int value = numbers[index1];
- numbers[index1] = numbers[index2];
- numbers[index2] = value;
- }
- else
- {
- numbers[index1] *= numbers[index2];
- }
- }
- }
- Console.WriteLine(String.Join(", ", numbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement