Advertisement
tanya_zheleva

Set

Jan 29th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ExamPreparation
  4. {
  5.     class Startup
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.             long result = 0;
  11.  
  12.             while (input != "END")
  13.             {
  14.                 string[] tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  15.  
  16.                 switch (tokens[0])
  17.                 {
  18.                     case "INC":
  19.                         long incOperand = long.Parse(tokens[1]);
  20.                         result = ++incOperand;
  21.                         break;
  22.                     case "DEC":
  23.                         long decOperand = long.Parse(tokens[1]);
  24.                         result = --decOperand;
  25.                         break;
  26.                     case "ADD":
  27.                         long first = long.Parse(tokens[1]);
  28.                         long second = long.Parse(tokens[2]);
  29.                         result = (first + second);
  30.                         break;
  31.                     case "MLA":
  32.                         long firstNum = long.Parse(tokens[1]);
  33.                         long secondNum = long.Parse(tokens[2]);
  34.                         result = (firstNum * secondNum);
  35.                         break;
  36.                 }
  37.  
  38.                 Console.WriteLine(result);
  39.                 input = Console.ReadLine();
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement