fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int*a=new int;
  6. int*b=new int;
  7. cout << "Podaj a: ";
  8. cin >> *a;
  9. cout << "Podaj b: ";
  10. cin >> *b;
  11. cout << "NWD(" << *a << "," << *b << ") = ";
  12. while (*a != *b) {
  13. if (*a < *b)
  14. *b -= *a;
  15. else
  16. *a -= *b;
  17. }
  18. cout << *a << endl;
  19. delete a;
  20. delete b;
  21. return 0;
  22. }
Success #stdin #stdout 0s 15224KB
stdin
54 81
stdout
Podaj a: Podaj b: NWD(54,81) = 27