Facebook
From Sharp Camel, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 66
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include "TestOrdenacion.h"
  4. #include "TestBusqueda.h"
  5. #include <iostream>
  6. #include "Constantes.h"
  7. using namespace std;
  8.  
  9. int menu() {
  10.     int opc;
  11.     do {
  12.         cout << "*** FAA. Practica 2. Curso 21/22";
  13.         cout << "\n\n\t\t\t\t\tAlumno. Pablo Ortega Ordonez";
  14.         cout << "\n\n*** MENU PRINCIPAL ***";
  15.         cout << "\n\n\t\t\t1.- MENU ORDENACION";
  16.         cout << "\n\n\t\t\t2.- MENU BUSQUEDA";
  17.         cout << "\n\n\t\t\t0.- Salir";
  18.         cout << "\n\n\t\t\t-----------------";
  19.         cout << "\n\n\t\t\tElige opcion: ";
  20.         cin >> opc;
  21.         system("cls");
  22.     } while (opc != 1 && opc != 2 && opc != 0);
  23.  
  24.     return opc;
  25.  
  26. }
  27.  
  28. int submenuOPC1() {
  29.     int opc;
  30.     do {
  31.         cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***";
  32.         cout << "\n\n0.- Burbuja";
  33.         cout << "\n\n1.- Insercion";
  34.         cout << "\n\n2.- Seleccion";
  35.         cout << "\n\n-----------------";
  36.         cout << "\n\nElige opcion: ";
  37.         cin >> opc;
  38.         system("cls");
  39.     } while (opc != 0 && opc != 1 && opc != 2);
  40.  
  41.     return opc;
  42. }
  43.  
  44.  
  45. int submenuOPC2() {
  46.     int opc;
  47.     do {
  48.         cout << "\n\n*** MENU BUSQUEDA ***";
  49.         cout << "\n\n1.- Probar los metodos de busqueda ";
  50.         cout << "\n\n2.- Obtener el caso medio de un metodo de busqueda";
  51.         cout << "\n\n3.- Comparar dos metodos";
  52.         cout << "\n\n4.- Comparar todos los metodos";
  53.         cout << "\n\n0.- Volver al menu principal";
  54.         cout << "\n\n-----------------";
  55.         cout << "\n\nElige opcion: ";
  56.         cin >> opc;
  57.         system("cls");
  58.     } while (opc != 0 && opc != 1 && opc != 2 && opc != 3 && opc != 4);
  59.  
  60.     return opc;
  61. }
  62.  
  63. int submenuOPC22() {
  64.     int opc;
  65.     do {
  66.         cout << "\n\n*** Metodo a estudiar para el caso medio ***";
  67.         cout << "\n\n0.- Busqueda Secuencial Iterativo ";
  68.         cout << "\n\n1.- Busqueda Binaria Iterativa";
  69.         cout << "\n\n2.- Busqueda de Interpolacion Iterativo";
  70.         cout << "\n\n-----------------";
  71.         cout << "\n\nElige opcion: ";
  72.         cin >> opc;
  73.         system("cls");
  74.     } while (opc != 0 && opc != 1 && opc != 2);
  75.  
  76.     return opc;
  77.  
  78. }
  79.  
  80. int submenuOPC23(int& opc2e) {
  81.     int opc;
  82.     int opc2;
  83.  
  84.     cout << "\n\n*** COMPARACION DE DOS METODOS DE BUSQUEDA ***";
  85.     cout << "\n\n0.- Busqueda Secuencial Iterativo ";
  86.     cout << "\n\n1.- Busqueda Binaria Iterativa";
  87.     cout << "\n\n2.- Busqueda de Interpolacion Iterativo";
  88.     cout << "\n\n-----------------";
  89.     do {
  90.         cout << "\n\nElige metodo 1: ";
  91.         cin >> opc;
  92.         if (opc != 0 && opc != 1 && opc != 2) {
  93.             cout << "Tiene que introducir un valor valido (1,2,3)";
  94.         }
  95.     } while (opc != 0 && opc != 1 && opc != 2);
  96.  
  97.     do {
  98.         cout << "\n\nElige metodo 2: ";
  99.         cin >> opc2;
  100.         if (opc != 0 && opc != 1 && opc != 2) {
  101.             cout << "Tiene que introducir un valor valido (1,2,3)";
  102.         }
  103.     } while (opc != 0 && opc != 1 && opc != 2);
  104.     opc2e = opc2;
  105.  
  106.     system("cls");
  107.  
  108.  
  109.     return opc;
  110. }
  111.  
  112.  
  113. int submenuOPC3(int &opc2e) {
  114.     int opc;
  115.     int opc2;
  116.  
  117.         cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***";
  118.         cout << "\n\n0.- Burbuja";
  119.         cout << "\n\n1.- Insercion";
  120.         cout << "\n\n2.- Seleccion";
  121.         cout << "\n\n-----------------";
  122.         do {
  123.             cout << "\n\nElige metodo 1: ";
  124.             cin >> opc;
  125.             if (opc != 0 && opc != 1 && opc != 2) {
  126.                 cout << "Tiene que introducir un valor valido (1,2,3)";
  127.             }
  128.         } while (opc != 0 && opc != 1 && opc != 2);
  129.  
  130.         do {
  131.             cout << "\n\nElige metodo 2: ";
  132.             cin >> opc2;
  133.             if (opc != 0 && opc != 1 && opc != 2) {
  134.                 cout << "Tiene que introducir un valor valido (1,2,3)";
  135.             }
  136.         } while (opc != 0 && opc != 1 && opc != 2);
  137.         opc2e = opc2;
  138.  
  139.         system("cls");
  140.    
  141.  
  142.     return opc;
  143. }
  144.  
  145.  
  146. int menu1() {
  147.     int opc;
  148.     do {
  149.         cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***";
  150.         cout << "\n\n\t\t\t1.- Probar los metodos de ordenacion";
  151.         cout << "\n\n\t\t\t2.- Obtener el caso medio de un metodo de ordenacion";
  152.         cout << "\n\n\t\t\t3.- Comparar dos metodos";
  153.         cout << "\n\n\t\t\t4.- Comparar todos los metodos";
  154.         cout << "\n\n\t\t\t0.- Salir";
  155.         cout << "\n\n\t\t\t-----------------";
  156.         cout << "\n\n\t\t\tElige opcion: ";
  157.         cin >> opc;
  158.         system("cls");
  159.     } while (opc != 1 && opc != 2 && opc != 3 && opc != 4 && opc != 0);
  160.  
  161.     return opc;
  162.  
  163. }
  164.  
  165.  
  166. void submenuOPC4() {
  167.     cout << "\n\n*** ANALISIS EXPERIMENTAL DE ALGORITMOS DE ORDENACION ***\n";
  168.     system("pause");
  169.  
  170. }
  171.  
  172.  
  173. int main()
  174. {
  175.     int opc;
  176.     int opc2;
  177.     int opc3;
  178.     int opc23, opc23s;
  179.     int opc2e;
  180.     TestOrdenacion test;
  181.     TestBusqueda testB;
  182.    
  183.     do {
  184.         opc = menu();
  185.         switch (opc)
  186.         {
  187.         case 1:
  188.             do {
  189.                 opc = menu1();
  190.                 switch (opc)
  191.                 {
  192.                 case 1:
  193.                     test.comprobarMetodosOrdenacion();
  194.                     break;
  195.  
  196.                 case 2:
  197.                     opc2 = submenuOPC1();
  198.                     test.casoMedio(opc2);
  199.                     break;
  200.  
  201.                 case 3:
  202.                     opc3 = submenuOPC3(opc2e);
  203.                     test.comparar(opc3, opc2e);
  204.                     break;
  205.  
  206.                 case 4:
  207.                     submenuOPC4();
  208.                     test.comparaTodos();
  209.                     break;
  210.  
  211.                 default:
  212.                     break;
  213.                 }
  214.                 cout << "\n"; system("pause");
  215.                 system("cls");
  216.             } while (opc != 0);
  217.         case 2:
  218.             do {
  219.                 opc2 = submenuOPC2();
  220.                 switch (opc2)
  221.                 {
  222.                 case 1:
  223.                     testB.comprobarMetodosBusqueda();
  224.                     break;
  225.  
  226.                 case 2:
  227.                     opc3 = submenuOPC22();
  228.                     switch (opc3)
  229.                     {
  230.                     case 0:
  231.                         testB.casoMedio(SECUENCIAL);
  232.                         //busqueda secuencial iterativo
  233.                         break;
  234.  
  235.                     case 1:
  236.                         testB.casoMedio(BINARIA);
  237.                         //busqueda binaria iterativa
  238.                         break;
  239.  
  240.                     case 2:
  241.                         testB.casoMedio(INTERPOLACION);
  242.                         //busqueda de interpolacion iterativo
  243.                         break;
  244.  
  245.                     default:
  246.                         break;
  247.                     }
  248.                     break;
  249.  
  250.                 case 3:
  251.                     //se obtiene dos algoritmos para comparar
  252.                     opc23 = submenuOPC23(opc23s);
  253.                     testB.comparar(opc23, opc23s);
  254.                     break;
  255.  
  256.                 case 4:
  257.                     testB.comparaTodos();
  258.                     break;
  259.  
  260.                 default:
  261.                     break;
  262.                 }
  263.                 break;
  264.  
  265.                 if (opc != 1 && opc != 2 && opc != 3 && opc != 4 && opc != 0) {
  266.                     cout << "Introduce una opcion correcta" << endl;
  267.                 }
  268.             } while (opc != 0);
  269.             break;
  270.  
  271.         default:
  272.             break;
  273.         }
  274.         cout << "\n"; system("pause");
  275.         system("cls");
  276.     } while (opc != 0);
  277.  
  278.  
  279.  
  280. }
  281.