Advertisement
DawidKubiak

Zad.6

Mar 22nd, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int iloraz (float a, float b)
  5. {
  6.     if (b==0)
  7. {
  8.     return -1;
  9. }
  10. else if (a<0)
  11. {
  12.     return -2;
  13. }
  14. else if (b<0)
  15. {
  16.     return -2;
  17. }
  18. else
  19. {
  20.     return a/b;
  21. }
  22. }
  23. int main()
  24. {
  25.     float a;
  26.     float b;
  27.     cin >> a;
  28.     cin >> b;
  29.     if (iloraz(a,b)==-1)
  30.     {
  31.         cout << "Nie dziel przez zero!" << endl;
  32.     }
  33.     else if (iloraz(a,b)==-2)
  34.     {
  35.         cout << "Liczby muszą być dodatnie" << endl;
  36.     }
  37.     else
  38.     {
  39.         cout << iloraz(a,b) << endl;
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement