Advertisement
Guest User

Kalkulator

a guest
Jan 25th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     long double a, b;
  11.     char op, cos;
  12.     cout << "Operatory: " << endl;
  13.     cout << "1. Dodawanie +" << endl;
  14.     cout << "2. Odejmowanie -" << endl;
  15.     cout << "3. Mnozenie *" << endl;
  16.     cout << "4. Dzielenie /" << endl;
  17.     cout << "5. Potegowanie: Liczba ^ Potega" << endl;
  18.     cout << "6. Pierwiastkowanie: Stopien # Potegowana liczba" << endl;
  19.  
  20.     poczatek:
  21.    
  22.  
  23.        
  24.             while (true) {
  25.                 if (cin.good()) {
  26.                 cin >> a >> op >> b;
  27.                 switch (op) {
  28.                 case '+': cout << a + b << '\n' << '\n' << '\n' << '\n' << '\n'; break;
  29.                 case '-': cout << a - b << '\n' << '\n' << '\n' << '\n' << '\n'; break;
  30.                 case '*': cout << a * b << '\n' << '\n' << '\n' << '\n' << '\n'; break;
  31.                 case '/': cout << a / b << '\n' << '\n' << '\n' << '\n' << '\n'; break;
  32.                 case '^': cout << pow(a, b) << '\n' << '\n' << '\n' << '\n' << '\n'; break;
  33.                 case '#': cout << pow(b, 1 / a) << '\n' << '\n' << '\n' << '\n' << '\n'; break;
  34.                 }
  35.             }
  36.         else {
  37.             cout << "Wprowadziles litere zamiast cyfry" << endl;
  38.             return 0;
  39.         }
  40.         }
  41.  
  42.  
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement