SvilenVelikov

Untitled

Oct 8th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 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 InstructionSet
  8. {
  9. class InstructionSet
  10. {
  11. static void Main()
  12. {
  13. string opCode = Console.ReadLine().ToLower();
  14. while (opCode != "end")
  15. {
  16. string[] codeArgs = opCode.Split(' ');
  17. long result = 0;
  18. //Console.WriteLine(codeArgs[0]);
  19. //Console.WriteLine(codeArgs[1]);
  20. //break;
  21.  
  22. switch (codeArgs[0])
  23. {
  24. case "inc":
  25. {
  26. int operandOne = int.Parse(codeArgs[1]);
  27. result = operandOne + 1;
  28. break;
  29. }
  30. case "dec":
  31. {
  32. int operandOne = int.Parse(codeArgs[1]);
  33. result = operandOne - 1;
  34. break;
  35. }
  36. case "add":
  37. {
  38. int operandOne = int.Parse(codeArgs[1]);
  39. int operandTwo = int.Parse(codeArgs[2]);
  40. result = (long)(operandOne + operandTwo);
  41. break;
  42. }
  43. case "mla":
  44. {
  45. int operandOne = int.Parse(codeArgs[1]);
  46. int operandTwo = int.Parse(codeArgs[2]);
  47. result = ((long)operandOne * (long)operandTwo);
  48. break;
  49. }
  50. default:
  51. break;
  52. }
  53.  
  54. Console.WriteLine(result);
  55. opCode = Console.ReadLine().ToLower();
  56.  
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment