0

I've this code. I need to do several experiments to obtain de average time it takes to do some methods. Instead of re-running and re-running the program, I want to put a segment of the code in a FOR bucle.

The problem is that my program never ends,it stays looping forever
Here is part of my code

int a= 0;

	for (a= 0; a= 20; a++){    // I WANT IT TO REPEAT FROM HERE (20 times)

	std::clock_t start;  
	double duration;

	// Populates the vector
	for(i=0; i<n; i++) v[i] = i;

	/*
        // Original vector
	cout << "Current Contents:\n";
	for(i=0; i<v.size(); i++) cout << v[i] << " ";
	cout << "\n\n";
        */
	//REARRANGE THE VECTOR
	random_shuffle( v.begin(), v.end());

        start = std::clock(); //Initiate de CLOCK
        rank_sort(v,n,v2); rearrange2(v,n,v2);[/CODE
        duration = (std::clock() - start) / (double) CLOCKS_PER_SEC;   

        std::cout<< <<duration<<endl;

   } // IT REPEATS UNTIL HERE
}

Edited by George_91: n/a

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by vishwanath.m
1

IN your for loop condition you gave a=20 while will always be true so it is in infinite loop...just change it to a<-20

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.