fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double dodaj(double a, double b) {
  6. double w;
  7. w = a + b;
  8. return w;
  9. }
  10.  
  11. double odejmij(double a, double b) {
  12. double w;
  13. w = a - b;
  14. return w;
  15. }
  16. double pomnoz(double a, double b) {
  17. double w;
  18. w = a*b;
  19. return w;
  20. }
  21. double podziel(double a, double b) {
  22. double w;
  23. w = a / b;
  24. return w;
  25. }
  26. double reszta(int a, int b) {
  27. double w;
  28. w = a%b;
  29. return w;
  30. }
  31.  
  32.  
  33.  
  34. int main() {
  35. double a, b;
  36. char znak;
  37. while (cin >> znak >> a >> b) {
  38. if (znak == '+') cout << dodaj(a, b) << endl;
  39. if (znak == '-') cout << odejmij(a, b) << endl;
  40. if (znak == '*') cout << pomnoz(a, b) << endl;
  41. if (znak == '/') cout << podziel(a, b) << endl;
  42. if (znak == '%') cout << reszta(a, b) << endl;
  43.  
  44. }
  45.  
  46. cin.get();
  47. cin.ignore();
  48. return 0;
  49.  
  50.  
  51. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty