Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int x, y, z;
  6.  
  7. string dzialanie,dodawanie,odejmowanie,mnozenie,dzielenie;
  8.  
  9. int main()
  10. {
  11.     while (1)
  12.     {
  13.         cout << "Wpisz pierwsza liczbe calkowita: ";
  14.         cin >> x;
  15.  
  16.         cout << "wpisz druga liczbe calkowita: ";
  17.         cin >> y;
  18.  
  19.         cout << "wybierz dzialanie: dodawanie,odejmowanie,mnozenie,dzielenie:" << endl;
  20.         cin >> dzialanie;
  21.  
  22.  
  23.  
  24.  
  25.  
  26.         if (dzialanie == "dodawanie")
  27.         {
  28.             z = x + y;
  29.             cout << z;
  30.         }
  31.         else if (dzialanie == "odejmowanie")
  32.         {
  33.             z = x - y;
  34.             cout << z;
  35.         }
  36.         else if (dzialanie == "mnozenie")
  37.         {
  38.             z = x * y;
  39.             cout << z;
  40.         }
  41.         else if (dzialanie == "dzielenie")
  42.  
  43.         {
  44.             if (y == 0)
  45.             {
  46.                 cout << "nie dzieli sie przez 0 cepie";
  47.             }
  48.             else
  49.             {
  50.                 z = x / y;
  51.                 cout << z;
  52.             }
  53.         }
  54.         else
  55.         {
  56.             cout << "blad";
  57.         }
  58.         cout << endl;
  59.     }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement