示例#1
0
int _tmain(int argc, _TCHAR* argv[])
{
	srand(time(NULL));

	cout << "Arbol de integers" << endl;
	ArbolBinario a;
	for (int i = 0; i < 10; ++i) {
		a.insertarElemento(new ElementoInt(rand() % 100));
	}

	cout << a << endl;


	cout << "Arbol de doubles" << endl;
	ArbolBinario d;
	for (int i = 0; i < 100; ++i) {
		d.insertarElemento(new ElementoDouble(((double)rand()*(100.00 - 0.00)) / (double)RAND_MAX));
	}

	cout << d << endl;

	cout << "Arbol de Personas" << endl;
	ArbolBinario q;

	//Array para guardar nombres del txt y seleccionarlos aleatoriamente
	string names[100];
	int k = 0;
	ifstream myFile("nombres.txt");
	while (!myFile.eof()){
		getline(myFile, names[k]);
		k++;
	}

	//Array para crear id no repetidos para cada Persona
	int id[100];
	int c = 0;
	while (c < 100){
		unsigned int number = rand() % (110889 - 10000) + 10000;
		if (findRepeat(id, number) != true){
			id[c] = number;
			c++;
		}
	}

	Persona * p[100];
	for (int i = 0; i < 100; i++){
		p[i] = new Persona(names[rand() % 100], id[i]);
	}

	for (int i = 0; i < 100; ++i) {
		q.insertarElemento(new ElementoPersona(p[i]));
	}

	cout << q << endl;

	system("pause");

	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	srand(time(NULL));

	ArbolBinario a;
	for (int i = 0; i < 10; ++i) {
		a.insertarElemento(new ElementoInt(rand() % 100));
	}
	ArbolBinario b;
	for (int i = 0; i < 10; ++i) {
		b.insertarElemento(new ElementoDouble((rand() % 100) + 1.1));
	}
	ArbolBinario c;
	Persona p1(5, "Pedro");
	Persona p2(2, "Andres");
	Persona p3(4, "Carmen");
	Persona p4(1, "Jose");
	Persona p5(3, "Maria");
	Persona p6(7, "Adriana");
	Persona p7(6, "Laura");
	c.insertarElemento(new ElementoPersona(p1));
	c.insertarElemento(new ElementoPersona(p2));
	c.insertarElemento(new ElementoPersona(p3));
	c.insertarElemento(new ElementoPersona(p4));
	c.insertarElemento(new ElementoPersona(p5));
	c.insertarElemento(new ElementoPersona(p6));
	c.insertarElemento(new ElementoPersona(p7));



	cout << "*** Inicia el arbol de ElementoInt" << endl;
	cout << a << endl;
	cout << "*** Finaliza el arbol de ElementoInt" << endl;
	cout << endl;
	cout << "*** Inicia el arbol de ElementoDouble" << endl;
	cout << b << endl;
	cout << "*** Finaliza el arbol de ElementoDouble" << endl;
	cout << "*** Inicia el arbol de ElementoPersona" << endl;
	cout << c << endl;
	cout << "*** Finaliza el arbol de ElementoPersona" << endl;

	system("PAUSE");
	return 0;
}