fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int a, b;
  7. cin >> a >> b;
  8. cout << "gcd(" << a << ", " << b << ") = "; // 組字串
  9.  
  10. int r;
  11. do {
  12. r = a % b;
  13. a = b;
  14. b = r;
  15. } while (r > 0);
  16.  
  17. cout << a << endl;
  18.  
  19.  
  20. return 0;
  21.  
  22. }
Success #stdin #stdout 0s 4544KB
stdin
54 32
stdout
gcd(54, 32) = 2