Advertisement
MeehoweCK

Untitled

Dec 7th, 2020
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     unsigned a, b;
  8.  
  9.     cout << "Podaj dwie liczby dodatnie: ";
  10.     cin >> a >> b;
  11.  
  12.     if(a * b == 0)
  13.     {
  14.         cout << "Co najmniej jedna z liczb jest rowna 0. Nie mozna znalezc wspolnego dzielnika :(\n";
  15.     }
  16.     else
  17.         while(a != b)
  18.         {
  19.             if(a > b)
  20.                 a = a - b;
  21.             if(b > a)
  22.                 b = b - a;
  23.         }
  24.     cout << "Najwiekszy wspolny dzielnik wynosi " << a << endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement