- #include <iostream>
- #include <stdlib.h>
- #include "TestOrdenacion.h"
- #include "TestBusqueda.h"
- #include <iostream>
- #include "Constantes.h"
- using namespace std;
- int menu() {
- int opc;
- do {
- cout << "*** FAA. Practica 2. Curso 21/22";
- cout << "\n\n\t\t\t\t\tAlumno. Pablo Ortega Ordonez";
- cout << "\n\n*** MENU PRINCIPAL ***";
- cout << "\n\n\t\t\t1.- MENU ORDENACION";
- cout << "\n\n\t\t\t2.- MENU BUSQUEDA";
- cout << "\n\n\t\t\t0.- Salir";
- cout << "\n\n\t\t\t-----------------";
- cout << "\n\n\t\t\tElige opcion: ";
- cin >> opc;
- system("cls");
- } while (opc != 1 && opc != 2 && opc != 0);
- return opc;
- }
- int submenuOPC1() {
- int opc;
- do {
- cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***";
- cout << "\n\n0.- Burbuja";
- cout << "\n\n1.- Insercion";
- cout << "\n\n2.- Seleccion";
- cout << "\n\n-----------------";
- cout << "\n\nElige opcion: ";
- cin >> opc;
- system("cls");
- } while (opc != 0 && opc != 1 && opc != 2);
- return opc;
- }
- int submenuOPC2() {
- int opc;
- do {
- cout << "\n\n*** MENU BUSQUEDA ***";
- cout << "\n\n1.- Probar los metodos de busqueda ";
- cout << "\n\n2.- Obtener el caso medio de un metodo de busqueda";
- cout << "\n\n3.- Comparar dos metodos";
- cout << "\n\n4.- Comparar todos los metodos";
- cout << "\n\n0.- Volver al menu principal";
- cout << "\n\n-----------------";
- cout << "\n\nElige opcion: ";
- cin >> opc;
- system("cls");
- } while (opc != 0 && opc != 1 && opc != 2 && opc != 3 && opc != 4);
- return opc;
- }
- int submenuOPC22() {
- int opc;
- do {
- cout << "\n\n*** Metodo a estudiar para el caso medio ***";
- cout << "\n\n0.- Busqueda Secuencial Iterativo ";
- cout << "\n\n1.- Busqueda Binaria Iterativa";
- cout << "\n\n2.- Busqueda de Interpolacion Iterativo";
- cout << "\n\n-----------------";
- cout << "\n\nElige opcion: ";
- cin >> opc;
- system("cls");
- } while (opc != 0 && opc != 1 && opc != 2);
- return opc;
- }
- int submenuOPC23(int& opc2e) {
- int opc;
- int opc2;
- cout << "\n\n*** COMPARACION DE DOS METODOS DE BUSQUEDA ***";
- cout << "\n\n0.- Busqueda Secuencial Iterativo ";
- cout << "\n\n1.- Busqueda Binaria Iterativa";
- cout << "\n\n2.- Busqueda de Interpolacion Iterativo";
- cout << "\n\n-----------------";
- do {
- cout << "\n\nElige metodo 1: ";
- cin >> opc;
- if (opc != 0 && opc != 1 && opc != 2) {
- cout << "Tiene que introducir un valor valido (1,2,3)";
- }
- } while (opc != 0 && opc != 1 && opc != 2);
- do {
- cout << "\n\nElige metodo 2: ";
- cin >> opc2;
- if (opc != 0 && opc != 1 && opc != 2) {
- cout << "Tiene que introducir un valor valido (1,2,3)";
- }
- } while (opc != 0 && opc != 1 && opc != 2);
- opc2e = opc2;
- system("cls");
- return opc;
- }
- int submenuOPC3(int &opc2e) {
- int opc;
- int opc2;
- cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***";
- cout << "\n\n0.- Burbuja";
- cout << "\n\n1.- Insercion";
- cout << "\n\n2.- Seleccion";
- cout << "\n\n-----------------";
- do {
- cout << "\n\nElige metodo 1: ";
- cin >> opc;
- if (opc != 0 && opc != 1 && opc != 2) {
- cout << "Tiene que introducir un valor valido (1,2,3)";
- }
- } while (opc != 0 && opc != 1 && opc != 2);
- do {
- cout << "\n\nElige metodo 2: ";
- cin >> opc2;
- if (opc != 0 && opc != 1 && opc != 2) {
- cout << "Tiene que introducir un valor valido (1,2,3)";
- }
- } while (opc != 0 && opc != 1 && opc != 2);
- opc2e = opc2;
- system("cls");
- return opc;
- }
- int menu1() {
- int opc;
- do {
- cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***";
- cout << "\n\n\t\t\t1.- Probar los metodos de ordenacion";
- cout << "\n\n\t\t\t2.- Obtener el caso medio de un metodo de ordenacion";
- cout << "\n\n\t\t\t3.- Comparar dos metodos";
- cout << "\n\n\t\t\t4.- Comparar todos los metodos";
- cout << "\n\n\t\t\t0.- Salir";
- cout << "\n\n\t\t\t-----------------";
- cout << "\n\n\t\t\tElige opcion: ";
- cin >> opc;
- system("cls");
- } while (opc != 1 && opc != 2 && opc != 3 && opc != 4 && opc != 0);
- return opc;
- }
- void submenuOPC4() {
- cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***\n";
- system("pause");
- }
- int main()
- {
- int opc;
- int opc2;
- int opc3;
- int opc23, opc23s;
- int opc2e;
- TestOrdenacion test;
- TestBusqueda testB;
- do {
- opc = menu();
- switch (opc)
- {
- case 1:
- do {
- opc = menu1();
- switch (opc)
- {
- case 1:
- test.comprobarMetodosOrdenacion();
- break;
- case 2:
- opc2 = submenuOPC1();
- test.casoMedio(opc2);
- break;
- case 3:
- opc3 = submenuOPC3(opc2e);
- test.comparar(opc3, opc2e);
- break;
- case 4:
- submenuOPC4();
- test.comparaTodos();
- break;
- default:
- break;
- }
- cout << "\n"; system("pause");
- system("cls");
- } while (opc != 0);
- case 2:
- do {
- opc2 = submenuOPC2();
- switch (opc2)
- {
- case 1:
- testB.comprobarMetodosBusqueda();
- break;
- case 2:
- opc3 = submenuOPC22();
- switch (opc3)
- {
- case 0:
- testB.casoMedio(SECUENCIAL);
- //busqueda secuencial iterativo
- break;
- case 1:
- testB.casoMedio(BINARIA);
- //busqueda binaria iterativa
- break;
- case 2:
- testB.casoMedio(INTERPOLACION);
- //busqueda de interpolacion iterativo
- break;
- default:
- break;
- }
- break;
- case 3:
- //se obtiene dos algoritmos para comparar
- opc23 = submenuOPC23(opc23s);
- testB.comparar(opc23, opc23s);
- break;
- case 4:
- testB.comparaTodos();
- break;
- default:
- break;
- }
- break;
- if (opc != 1 && opc != 2 && opc != 3 && opc != 4 && opc != 0) {
- cout << "Introduce una opcion correcta" << endl;
- }
- } while (opc != 0);
- break;
- default:
- break;
- }
- cout << "\n"; system("pause");
- system("cls");
- } while (opc != 0);
- }