示例#1
0
int test3() {
	srand(time(NULL));
	std::cout << "QUICKSORT" << std::endl;
	Float<&sort> tab2[20];
	int i,taille = 500;
	std::cout << "creation du tableau" << std::endl;
	for(i=0;i<taille;i++) {
		tab2[i] = 1 + (int)(((double)rand())/((double)RAND_MAX+1)*(double)1000);
	}
	sort.time_reset();
	std::cout << "triage du tableau" << std::endl;
	quicksort<&sort>(tab2,0,taille);	
	std::cout << "[";
	for (int i=0; i<taille; i++) {
		std::cout << tab2[i];
		if (i < taille - 1)
			std::cout << ", ";
		if (i%20==1)
			std::cout << std::endl;
	}
	std::cout << "]" << std::endl;
	sort.show_stats();

	return 0;

}
示例#2
0
int test1() {
	//st.time_reset();
	naive.time_reset();
	std::cout << "SOMME NAIVE" << std::endl;
	sommeNaive<&naive>(1,32000);
	naive.show_stats();
	std::cout << std::endl;

	//gauss.time_reset();
	std::cout << "SOMME DE GAUSS" << std::endl;
	sommeGauss<&gauss>(1,320);
	gauss.show_stats();
	std::cout << std::endl;

	//std::cout << "TRI BULLES" << std::endl;

	std::cout << "TRI SELECTION" << std::endl;
	int taille = 10;
	Float<&s> tab1[10] = {12.1,48.3,5.4,9,1.7,20.5,1.3,24.5,3,7};
	// triBulles<&s>(tab,taille);

	// s.time_reset();
	triSelection<&s>(tab1,taille);
	std::cout << "[";
	for (int i=0; i<taille; i++) {
		std::cout << tab1[i];
		if (i < taille-1)
			std::cout << ", ";
	}
	std::cout << "]" << std::endl;
	s.show_stats();

	// sort.time_reset();
	std::cout << "QUICKSORT" << std::endl;
	Float<&sort> tab2[20];
	int i;
	for(i=0;i<20;i++) {
		tab2[i]=20-i;
	}

	quicksort<&sort>(tab2,0,19);	
	std::cout << "[";
	for (int i=0; i<20; i++) {
		std::cout << tab2[i];
		if (i < 19)
			std::cout << ", ";
	}
	std::cout << "]" << std::endl;
	sort.show_stats();

	return 0;
}
示例#3
0
int main() {
	programme.time_reset();
	test3();
	programme.print_time();

}