NedyalkoKikov

ArrModifier

Jun 11th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 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 ArrayModifier
  8. {
  9. class ArrayModifier
  10. {
  11. static void Main()
  12. {
  13. long[] arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
  14. while (true)
  15. {
  16. string[] command = Console.ReadLine().Split(' ');
  17. if(command[0] == "end")
  18. {
  19. break;
  20. }
  21. else if(command[0] == "swap")
  22. {
  23. int index1 = int.Parse(command[1]);
  24. int index2 = int.Parse(command[2]);
  25. int oldValue = arr[index1];
  26. arr[index1] = arr[index2];
  27. arr[index2] = oldValue;
  28. }
  29. else if(command[0] == "multiply")
  30. {
  31. int index1 = int.Parse(command[1]);
  32. int index2 = int.Parse(command[2]);
  33. arr[index1] = arr[index1] * arr[index2];
  34. }
  35. else if(command[0] == "decrease")
  36. {
  37. for (int i = 0; i < arr.Length; i++)
  38. {
  39. arr[i]--;
  40. }
  41. }
  42. }
  43. Console.WriteLine(string.Join(", ",arr));
  44.  
  45.  
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment