Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikola-Andreev/e4fd15622e553fcbc74f6ba53f7e7633 to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/e4fd15622e553fcbc74f6ba53f7e7633 to your computer and use it in GitHub Desktop.
Instruction Set
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Praktice
{
class Program
{
static void Main(string[] args)
{
string opCode = string.Empty;
decimal result = 0;
List<decimal> output = new List<decimal>();
while (opCode != "END")
{
if (opCode!=string.Empty)
{
string[] codeArgs = opCode.Split(' ');
switch (codeArgs[0])
{
case "INC":
{
result = decimal.Parse(codeArgs[1]);
result++;
break;
}
case "DEC":
{
result = decimal.Parse(codeArgs[1]);
result--;
break;
}
case "ADD":
{
decimal operandOne = decimal.Parse(codeArgs[1]);
decimal operandTwo = decimal.Parse(codeArgs[2]);
result = operandOne + operandTwo;
break;
}
case "MLA":
{
decimal operandOne = decimal.Parse(codeArgs[1]);
decimal operandTwo = decimal.Parse(codeArgs[2]);
result = operandOne * operandTwo;
break;
}
}
output.Add(result);
}
opCode = Console.ReadLine();
}
foreach (var item in output)
{
Console.WriteLine(item);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment