All pastes #979692 Raw Edit

Untitled

public cpp v1 · immutable
·published 2008-04-10 15:12 UTC
rendered paste body
// -*- mode: c++ -*-// $Id: nestedloop.g++,v 1.2 2001/06/20 03:20:02 doug Exp $// http://www.bagley.org/~doug/shootout///** This copy courtesy of http://www.kano.net/javabench///**  Loop to prevent overflow (and provide 'non-trivial' measurement time)//**  Added Timer() code#include <ctime>#include <iostream>#include <string>#include <cstdlib>using namespace std;int main(int argc, char *argv[]) {	int n = ((argc == 2) ? atoi(argv[1]) : 1);	int x = 0;    //const int n = 30;    clock_t start=clock();     while(n--) {		//x = 0;	    for (int a=0; a<n; ++a)		    for (int b=0; b<n; ++b)			    for (int c=0; c<n; ++c)				    for (int d=0; d<n; ++d)					    for (int e=0; e<n; ++e)						    for (int f=0; f<n; ++f)							    x++;    }	cout << x << endl;	clock_t endt=clock(); 	std::cout <<"Time: " << double(endt-start)/CLOCKS_PER_SEC * 1000 << " ms\n"; 	return(0);}