31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

unsigned fibonacci(unsigned n)<br />

{<br />

static leda::timer t("fibonacci");<br />

// report total time upon destruction of t<br />

leda::timer::measure m(t);<br />

// starts the timer t when m is constructed, and stops t<br />

// when m is destroyed, i.e. when the function returns<br />

}<br />

if (n < 1) return 0;<br />

else if (n == 1) return 1;<br />

else return fibonacci(n-1) + fibonacci(n-2);<br />

int main()<br />

{<br />

std::cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!