YAMILDIAZ

Laragym funciones.cpp

Jun 19th, 2023
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.06 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include "funciones.h"
  3.  
  4. using namespace std;
  5.  
  6. void mostrarMenu()
  7. {
  8.     cout << "MENU" << endl;
  9.     cout << "----" << endl;
  10.     cout << "0-CARGAR DATOS" << endl;
  11.     cout << "1-PUNTO A" << endl;
  12.     cout << "2-PUNTO B" << endl;
  13.     cout << "3-PUNTO C" << endl;
  14.     cout << "9-SALIR" << endl;
  15.     cout << endl << "SELECCIONE UNA OPCION: ";
  16. }
  17.  
  18. void cargarDatos(int mat[][10])
  19. {
  20.     system("cls");
  21.     //cout << "CARGAR DATOS" << endl;
  22.  
  23.     int nroEntrenamiento, cliente, tipo, minutos;
  24.  
  25.     cout << "Numero de entrenamiento: ";
  26.     cin >> nroEntrenamiento;
  27.  
  28.     while(nroEntrenamiento != 0)
  29.     {
  30.         cout << "Cliente: ";
  31.         cin >> cliente;
  32.         cout << "Tipo de entrenamiento: ";
  33.         cin >> tipo;
  34.         cout << "Tiempo del entrenamiento: ";
  35.         cin >> minutos;
  36.  
  37.         //calculos
  38.         /*  APROVECHO QUE LOS NÚMEROS DE CLIENTE Y TIPO DE ENTRENAMIENTO SON CONSECUTIVOS
  39.         (AUNQUE NO COMIENCEN DESDE 0, NO IMPORTA)
  40.         Y CREO UNA MATRIZ QUE ME SERVIRÁ PARA RESOLVER TODOS LOS PUNTOS
  41.         EN UNA DIMENSIÓN LOS CLIENTES, EN LA OTRA LOS TIPOS DE ENTRENAMIENTO
  42.         Y EN LA INTERSECCIÓN DE AMBAS ("CELDAS") GUARDO LOS MINUTOS ENTRENADOS  */
  43.         mat[cliente - 101][tipo - 1] += minutos;
  44.  
  45.         cout << "Numero de entrenamiento: ";
  46.         cin >> nroEntrenamiento;
  47.     }
  48.  
  49.     system("pause");
  50.     system("cls");
  51. }
  52.  
  53. void puntoA(int mat[][10], int clientes, int tipos)
  54. {
  55.     system("cls");
  56.     //cout << "PUNTO A" << endl;
  57.  
  58.     int c, t;
  59.     int minutosTotales;
  60.     int horas = 0, mins = 0;
  61.  
  62.     for(c=0; c<clientes; c++)   //RECORRO CLIENTES
  63.     {
  64.         minutosTotales = 0;
  65.  
  66.         for(t=0; t<tipos; t++)    //RECORRO TIPOS DE ENTRENAMIENTO
  67.         {
  68.             minutosTotales += mat[c][t];
  69.         }
  70.  
  71.         if(minutosTotales > 0)
  72.         {
  73.  
  74.             cout << "Cliente: " << c + 101 << endl;
  75.             //cout << "Minutos de entrenamiento: " << minutosTotales << endl;
  76.             convertirMinutos(minutosTotales, horas, mins);
  77.  
  78.             if(horas > 0 && mins > 0)
  79.             {
  80.                 cout << "Entreno " << horas << " hora/s y " << mins << " minuto/s" << endl;
  81.             }
  82.             else if(horas > 0)
  83.             {
  84.                 cout << "Entreno " << horas << " hora/s" << endl;
  85.             }
  86.             else
  87.             {
  88.                 cout << "Entreno " << mins << " minuto/s" << endl;
  89.             }
  90.         }
  91.     }
  92.  
  93.     system("pause");
  94.     system("cls");
  95. }
  96.  
  97. void puntoB(int mat[][10], int clientes, int tipos)
  98. {
  99.     system("cls");
  100.     //cout << "PUNTO B" << endl;
  101.  
  102.     int c, t, minutosTotales;
  103.     bool mostroCartel;
  104.  
  105.     for(c=0; c<clientes; c++)   //RECORRO CLIENTES
  106.     {
  107.         minutosTotales = 0;
  108.         mostroCartel = false;
  109.  
  110.         for(t=0; t<tipos; t++)    //RECORRO TIPOS DE ENTRENAMIENTO
  111.         {
  112.             minutosTotales += mat[c][t];
  113.             if(minutosTotales > 0 && !mostroCartel)
  114.             {
  115.                 cout << endl;
  116.                 cout << "Cliente: " << c + 101 << " entreno los siguientes tipos: " << endl;
  117.                 mostroCartel = true;
  118.             }
  119.             if(mat[c][t] > 0)
  120.             {
  121.                 cout << t + 1 << "\t";
  122.             }
  123.         }
  124.     }
  125.     cout << endl;
  126.  
  127.     system("pause");
  128.     system("cls");
  129. }
  130.  
  131. void puntoC(int mat[][10], int clientes, int tipos)
  132. {
  133.     system("cls");
  134.     //cout << "PUNTO C" << endl;
  135.  
  136.     int t, c;
  137.     int minutosPorTipo;
  138.     cout << "Los tipos de entrenamiento que no se realizaron por ningun cliente son: " << endl;
  139.  
  140.     for(t=0; t<tipos; t++)    //RECORRO TIPOS DE ENTRENAMIENTO
  141.     {
  142.         minutosPorTipo = 0;
  143.         for(c=0; c<clientes; c++)   //RECORRO CLIENTES
  144.         {
  145.             minutosPorTipo += mat[c][t];
  146.         }
  147.         if(minutosPorTipo == 0){
  148.               cout << t + 1 << "\t";
  149.         }
  150.     }
  151.     cout << endl;
  152.  
  153.     system("pause");
  154.     system("cls");
  155. }
  156.  
  157. void convertirMinutos(int minutosTotales, int &horas, int &mins)
  158. {
  159.     horas = minutosTotales / 60;
  160.     mins = minutosTotales % 60;
  161. }
Advertisement
Add Comment
Please, Sign In to add comment