fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // zdefiniuj funkcję
  5. int nwd(int a, int b) {
  6. while(b!=0) {
  7. int pom=b;
  8. b=a%b;
  9. a=pom;
  10. }
  11. return a;
  12. }
  13.  
  14. // zdefiniuj funkcję
  15. int rzad(int goscie, int gospodarze) {
  16. return nwd(goscie, gospodarze);
  17. }
  18.  
  19. // testy
  20. int main() {
  21. cout << rzad(72, 90) << " " << rzad(24, 36) << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
18 12