I'm trying to use chrono to create my own clocks, but first i'm developing a basic example:
#include <cstdlib>
#include <iostream>
#include <chrono>
#include <ctime>
using namespace std;
int fibonacci(int n)
{
if (n < 3) return 1;
return fibonacci(n-1) + fibonacci(n-2);
}
int main(int argc, char** argv) {
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
int result = fibonacci(42);
end = std::chrono::system_clock::now();
int elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>
(end-start).count();
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
std::cout << "finished computation at " << std::ctime(&end_time)
<< "elapsed time: " << elapsed_seconds << "s\n";
return 0;
}
But this simple example doesn't work, I add at Project->Properties->Build-> C++ Compiles and Linker in Aditional Options ' -std=c++11' and still not working
When I running i get:
RUN FAILED (exit value -1.073.741.511, total time: 2s)
Aucun commentaire:
Enregistrer un commentaire