Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int nwd(int a, int b)
  7. {
  8. while(a!=b)
  9. {
  10. if(a>b)
  11. a=a-b;
  12. else
  13. b=b-a;
  14. }
  15. return a;
  16. }
  17.  
  18. int main()
  19. {
  20. int a,b;
  21. cout<< "podaj pierwsza liczbe a:";
  22. cin>>a;
  23. cout<<"podaj druga liczbe b:";
  24. cin>>b;
  25. cout<< "nwd("<< a << "," << b << ") ma wartosc: " <<nwd(a,b);
  26. cin.ignore();
  27. getchar();
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement