Advertisement
Pietras286

Kalkulator

Dec 13th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 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.  
  7. namespace Problem26
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string tekst;
  14.             while ((tekst = Console.ReadLine()) != null)
  15.             {
  16.                 string[] tab = tekst.Split(' ');
  17.                 int a = int.Parse(tab[1]);
  18.                 int b = int.Parse(tab[2]);
  19.                 switch (tab[0])
  20.                 {
  21.                     case "+":
  22.                         Console.WriteLine(a + b);
  23.                         break;
  24.                     case "-":
  25.                         Console.WriteLine(a - b);
  26.                         break;
  27.                     case "*":
  28.                         Console.WriteLine(a * b);
  29.                         break;
  30.                     case "/":
  31.                         Console.WriteLine(a / b);
  32.                         break;
  33.                     default:
  34.                         Console.WriteLine(a % b);
  35.                         break;
  36.                 }
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement