Guest User

InstructionSet

a guest
May 26th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class InstructionSet
  5. {
  6.     static void Main(string[] args)
  7.     {
  8.         string line = null;
  9.         while((line=Console.ReadLine())!="END")
  10.         {
  11.                
  12.             double sum =1;
  13.             string[] input = line.Trim().Split().ToArray();
  14.  
  15.             if (input[0] == "INC")
  16.             {
  17.                 for (int i = 1; i < input.Length; i++)
  18.                 {
  19.                     double a = double.Parse(input[i]);
  20.                     Console.WriteLine(a+1);
  21.                 }
  22.             }
  23.             if (input[0] == "DEC")
  24.             {
  25.                 for (int i = 1;i< input.Length; i++)
  26.                 {
  27.                     double a = double.Parse(input[i]);
  28.                     Console.WriteLine(a-1);
  29.                 }
  30.             }
  31.             if (input[0] == "ADD")
  32.             {
  33.                 for (int i = 1 ; i < input.Length; i++)
  34.                 {
  35.  
  36.                     double a = double.Parse(input[i]);
  37.                     sum +=a ;
  38.                     if(i == input.Length-1)
  39.                     {
  40.                         Console.WriteLine(sum-1);
  41.                     }
  42.                 }
  43.             }
  44.             if (input[0] == "MLA")
  45.             {
  46.                 for (int i = 1; i < input.Length; i++)
  47.                 {
  48.                     double a = double.Parse(input[i]);
  49.                     sum *= a;
  50.                     if (i == input.Length - 1)
  51.                     {
  52.                         Console.WriteLine(sum);
  53.                     }
  54.                 }
  55.             }
  56.             if (input[0] == "END")
  57.             {
  58.                 break;
  59.             }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment