Advertisement
tochka

Untitled

Oct 14th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp95
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<long> numbers = Console.ReadLine()
  14. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  15. .Select(long.Parse)
  16. .ToList();
  17.  
  18. string[] commands = Console.ReadLine().Split(' ');
  19.  
  20. while (commands[0] != "end")
  21. {
  22. if (commands[0] == "swap")
  23. {
  24. long indexOne = long.Parse(commands[1]);
  25. long indexTwo = long.Parse(commands[2]);
  26.  
  27. long temp = numbers[(int)indexOne];
  28. numbers[(int)indexOne] = numbers[(int)indexTwo];
  29. numbers[(int)indexTwo] = temp;
  30.  
  31. }
  32.  
  33. else if (commands[0] == "multiply")
  34. {
  35. long indexOne = long.Parse(commands[1]);
  36. long indexTwo = long.Parse(commands[2]);
  37.  
  38. long sum = numbers[(int)indexOne] * numbers[(int)indexTwo];
  39. numbers[(int)indexOne] = sum;
  40. }
  41.  
  42. else if(commands[0] == "decrease")
  43. {
  44. for (long i = 0; i < numbers.Count; i++)
  45. {
  46. numbers[(int)i]--;
  47. }
  48. }
  49.  
  50. commands = Console.ReadLine().Split(' ');
  51. }
  52. Console.WriteLine(string.Join(", ", numbers));
  53. }
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement