Facebook
From Funky Pudu, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 111
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02.ArrayModifier
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> list = Console.ReadLine().Split().Select(int.Parse).ToList();
  12.  
  13.             string input = Console.ReadLine();
  14.  
  15.             while (input != "end")
  16.             {
  17.                 string[] commands = input.Split();
  18.                 string command = commands[0];
  19.  
  20.                 if (commands[0] == "swap")
  21.                 {
  22.                         int index1 = int.Parse(commands[1]);
  23.                         int index2 = int.Parse(commands[2]);
  24.  
  25.                         int temp = list[index1];
  26.                         list[index1] = list[index2];
  27.                         list[index2] = temp;
  28.  
  29.                 }
  30.                 else if (commands[0] == "multiply")
  31.                 {
  32.                     int index1 = int.Parse(commands[1]);
  33.                     int index2 = int.Parse(commands[2]);
  34.                    
  35.                     list[index1] *= list[index2];
  36.                    
  37.                 }
  38.                 else if (commands[0] == "decrease")
  39.                 {
  40.                     for (int i = 0; i < list.Count; i++)
  41.                     {
  42.                         list[i] -= 1;
  43.                     }
  44.                 }
  45.  
  46.                 input = Console.ReadLine();
  47.             }
  48.  
  49.             Console.WriteLine(String.Join(", ", list));
  50.         }
  51.  
  52.  
  53.     }
  54. }
  55.