All pastes #980068 Raw Edit

Someone

public cpp v1 · immutable
·published 2008-04-10 19:47 UTC
rendered paste body
// -*- mode: c++ -*-// $Id: random.g++,v 1.7 2001/07/31 19:47:03 doug Exp $// http://www.bagley.org/~doug/shootout///** This copy courtesy of http://www.kano.net/javabench///**  Added Timer() code#include <ctime>#include <iostream>#include <string>#include <cstdlib>using namespace std;static const int IM = 139968;static const int IA = 3877;static const int IC = 29573;double gen_random(double max) {	static long last = 42;	last = (last * IA + IC) % IM;	return( max * last / IM );}int main(int argc, char *argv[]) {	int N = ((argc == 2) ? atoi(argv[1]) : 1);    clock_t start=clock();	double result = 0;    	while (N-->0) {		result = gen_random(100.0);	}	cout.precision(9);	cout.setf(ios::fixed);	cout << result << endl;    clock_t endt=clock(); 	std::cout <<"Time: " << double(endt-start)/CLOCKS_PER_SEC * 1000 << " ms\n"; 	return(0);}