Advertisement
JakubJaneczek

Zadanie 17

Apr 7th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int a, b;
  5. int nwd(int a, int b){
  6.     do{
  7.         if(a>b){
  8.            a=a-b;
  9.         } else{
  10.             b=b-a;
  11.         }
  12.     }
  13.     while(a!=b);
  14.     cout << "Najwiekszy wspolny dzielnik: " << a << endl;
  15. }
  16.  
  17. int main(){
  18.     cout << "Dla liczb 36,6" << endl;
  19.     nwd(36,6);
  20.     cout << "Dla liczb 72,16" << endl;
  21.     nwd(72,16);
  22.     cout << "Dla liczb 125,50" << endl;
  23.     nwd(125,50);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement