fork download
  1. #include <iostream>
  2. #include <chrono>
  3.  
  4. using namespace std;
  5. using namespace std::chrono;
  6.  
  7. int mcd(int a, int b) {
  8. if (b == 0) return a;
  9. return mcd(b, a % b);
  10. }
  11.  
  12. int main() {
  13. int a = 999999, b = 1000000;
  14.  
  15. auto inicio = high_resolution_clock::now();
  16. int resultado = mcd(a, b);
  17. auto fin = high_resolution_clock::now();
  18.  
  19. auto duracion = duration_cast<nanoseconds>(fin - inicio);
  20.  
  21. cout << "MCD de " << a << " y " << b << " es: " << resultado << endl;
  22. cout << "Tiempo de ejecución: " << duracion.count() << " nanosegundos" << endl;
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
MCD de 999999 y 1000000 es: 1
Tiempo de ejecución: 109 nanosegundos