MichalWalczak

Zad 6

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