Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _16.DebuggingExerciseInstructionSet
- {
- class StartUp
- {
- static void Main()
- {
- string opCode = Console.ReadLine().ToUpper();
- long result = 0;
- long operandOne = 0;
- long operandTwo = 0;
- while (opCode != "END")
- {
- string[] codeArgs = opCode.Split(' ');
- switch (codeArgs[0])
- {
- case "INC":
- {
- operandOne = int.Parse(codeArgs[1]);
- result = operandOne + 1;
- Console.WriteLine(result);
- break;
- }
- case "DEC":
- {
- operandOne = int.Parse(codeArgs[1]);
- result = operandOne - 1;
- Console.WriteLine(result);
- break;
- }
- case "ADD":
- {
- operandOne = int.Parse(codeArgs[1]);
- operandTwo = int.Parse(codeArgs[2]);
- result = operandOne + operandTwo;
- Console.WriteLine(result);
- break;
- }
- case "MLA":
- {
- operandOne = int.Parse(codeArgs[1]);
- operandTwo = int.Parse(codeArgs[2]);
- result = operandOne * operandTwo;
- Console.WriteLine(result);
- break;
- }
- }
- opCode = Console.ReadLine().ToUpper();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment