MichalWalczak

Zad 18

Mar 29th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int x, y;
  7. int NWW(int a, int b){
  8.     if(a%b==0){
  9.         int c=b;
  10.         return a;
  11.     }
  12.     else{
  13.         int c;
  14.         int a1=a;
  15.         int b1=b;
  16.         while(a%b!=0){
  17.             c=a%b;
  18.             a=b;
  19.             b=c;
  20.         }
  21.         return (a1*b1)/b;
  22.     }
  23. }
  24.  
  25. int main()
  26. {
  27.     cout << "Podaj dwie liczby, aby obliczyc NWW" << endl;
  28.     cin>>x;
  29.     cin>>y;
  30.     cout<<NWW(x,y);
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment