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;
- using System.Numerics;
- namespace _04.ArrayModifier
- {
- class ArrayModifier
- {
- static void Main(string[] args)
- {
- long[] array = Console.ReadLine().ToLower().Split(' ').Select(long.Parse).ToArray();
- string[] input = Console.ReadLine().Split();
- while (input[0] != "end")
- {
- switch (input[0])
- {
- case "swap":
- SwapInts(array, long.Parse(input[1]), long.Parse(input[2]));
- break;
- case "multiply":
- MultiplyInt(array, long.Parse(input[1]), long.Parse(input[2]));
- break;
- case "decrease":
- DecreaseInt(array);
- break;
- }
- input = Console.ReadLine().ToLower().Split();
- }
- Console.WriteLine(string.Join(", ", array));
- }
- static long[] MultiplyInt(long[] array, long pos1, long pos2)
- {
- array[pos1] = array[pos1] * array[pos2];
- return array;
- }
- //23 -84 321 87 42 90 -123
- static long[] DecreaseInt(long[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- array[i] -= 1;
- }
- return array;
- }
- static long[] SwapInts(long[] array, long position1, long position2)
- {
- long temp = array[position1];
- array[position1] = array[position2];
- array[position2] = temp;
- return array;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement