Advertisement
VanessaShopping

15. Instruction Set

Oct 10th, 2016
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 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. using System.Numerics;
  7.  
  8. namespace _15.Instruction_Set
  9. {
  10.     class InstructionSet
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string opCode = Console.ReadLine();
  15.  
  16.             while (opCode != "END")
  17.             {
  18.                 string[] codeArgs = opCode.Split(' ');
  19.  
  20.                 BigInteger result = 0;
  21.                 switch (codeArgs[0])
  22.                 {
  23.                     case "INC":
  24.                         {
  25.                             int operandOne = int.Parse(codeArgs[1]);
  26.                             result = ++operandOne;
  27.                             break;
  28.                         }
  29.                     case "DEC":
  30.                         {
  31.                             int operandOne = int.Parse(codeArgs[1]);
  32.                             result = --operandOne;
  33.                             break;
  34.                         }
  35.                     case "ADD":
  36.                         {
  37.                             int operandOne = int.Parse(codeArgs[1]);
  38.                             int operandTwo = int.Parse(codeArgs[2]);
  39.                             result = operandOne + operandTwo;
  40.                             break;
  41.                         }
  42.                     case "MLA":
  43.                         {
  44.                             int operandOne = int.Parse(codeArgs[1]);
  45.                             int operandTwo = int.Parse(codeArgs[2]);
  46.                             result = (BigInteger)(operandOne) * (BigInteger)(operandTwo);
  47.                             break;
  48.                         }
  49.                 }
  50.                 Console.WriteLine(result);
  51.                 opCode = Console.ReadLine();
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement