All pastes #979615 Raw Edit

Untitled

public cpp v1 · immutable
·published 2008-04-10 13:59 UTC
rendered paste body
// -*- mode: c++ -*-// $Id: fibo.g++,v 1.3 2001/06/20 03:20:02 doug Exp $// http://www.bagley.org/~doug/shootout///** This copy courtesy of http://www.kano.net/javabench///**  inline and change fib() to type int (as with the Java version)//**  Added Timer() code#include <iostream>#include <string>#include <cstdlib>#include <ctime>using namespace std;inline int fib(unsigned int n) {    if (n < 2)        return(1);    else        return(fib(n-2) + fib(n-1));}int main(int argc, char *argv[]) {	int n = ((argc == 2) ? atoi(argv[1]) : 1);    clock_t start=clock(); 	cout << fib(n) << endl;    clock_t endt=clock(); 	std::cout <<"Time: " << double(endt-start)/CLOCKS_PER_SEC * 1000 << " ms\n"; 	return(0);}