Advertisement
orlandoju

ejer8tp6bis2.cpp

May 26th, 2024 (edited)
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <clocale>
  3. using namespace std;
  4.  
  5. int main() {
  6.     setlocale(LC_ALL, "");
  7.  
  8.     const int CLIENTES = 50;
  9.     const int TIPOSENT = 10;
  10.     int nroEntrenamiento, minutosEnt, cliente, tipoEnt;
  11.     int tiempoTotalCliente[CLIENTES] = {};
  12.     bool tiposEntPorCliente[CLIENTES][TIPOSENT] = {};
  13.     int minEntPorCliente[CLIENTES][TIPOSENT] = {};
  14.     int maxTiempoEntrenamiento = 0, maxClienteEnt = 0;
  15.  
  16.     cout << "Ingrese número de entrenamiento (0 para terminar): " << endl;
  17.     cin >> nroEntrenamiento;
  18.  
  19.     while (nroEntrenamiento != 0) {
  20.         cout << "Ingrese cliente (101-150): " << endl;
  21.         cin >> cliente;
  22.         cout << "Ingrese tiempo total de entrenamiento en minutos: " << endl;
  23.         cin >> minutosEnt;
  24.         cout << "Ingrese el tipo de entrenamiento que realizó (1-10): " << endl;
  25.         cin >> tipoEnt;
  26.  
  27.         tiempoTotalCliente[cliente - 101] += minutosEnt;
  28.         tiposEntPorCliente[cliente - 101][tipoEnt - 1] = true;
  29.         minEntPorCliente[cliente - 101][tipoEnt - 1] += minutosEnt;
  30.  
  31.         if (tiempoTotalCliente[cliente - 101] > maxTiempoEntrenamiento) {
  32.             maxTiempoEntrenamiento = tiempoTotalCliente[cliente - 101];
  33.             maxClienteEnt = cliente;
  34.         }
  35.  
  36.         cout << "--------------------------------------" << endl;
  37.         cout << "Ingrese número de entrenamiento (0 para terminar): " << endl;
  38.         cin >> nroEntrenamiento;
  39.     }
  40.  
  41.     // 1 - Tiempo total de entrenamiento por cliente
  42.     cout << "Tiempo total de entrenamiento por cliente:" << endl;
  43.     for (int i = 0; i < CLIENTES; i++) {
  44.         if (tiempoTotalCliente[i] > 0) {
  45.             int horas = tiempoTotalCliente[i] / 60;
  46.             int minutos = tiempoTotalCliente[i] % 60;
  47.             cout << "Cliente " << (i + 101) << ": " << horas << " horas y " << minutos << " minutos" << endl;
  48.         }
  49.     }
  50.  
  51.     // 2 - Tipos de entrenamiento realizados por cada cliente
  52.     cout << "Tipos de entrenamiento realizados por cada cliente:" << endl;
  53.     for (int i = 0; i < CLIENTES; i++) {
  54.         bool tuvoTiposEnt = false;
  55.         for (int j = 0; j < TIPOSENT; j++) {
  56.             if (tiposEntPorCliente[i][j]) {
  57.                 if (!tuvoTiposEnt) {
  58.                     cout << "Cliente " << (i + 101) << ": ";
  59.                     tuvoTiposEnt = true;
  60.                 }
  61.                 cout << (j + 1) << " ";
  62.             }
  63.         }
  64.         if (tuvoTiposEnt) {
  65.             cout << endl;
  66.         }
  67.     }
  68.  
  69.     // 3 - Minutos por tipo de entrenamiento por cliente
  70.     cout << "Minutos por tipo de entrenamiento por cliente:" << endl;
  71.     for (int i = 0; i < CLIENTES; i++) {
  72.         for (int j = 0; j < TIPOSENT; j++) {
  73.             if (minEntPorCliente[i][j] > 0) {
  74.                 cout << "Cliente " << (i + 101) << ", Tipo de entrenamiento " << (j + 1) << ": " << minEntPorCliente[i][j] << " minutos" << endl;
  75.             }
  76.         }
  77.     }
  78.  
  79.     // 4 - Cliente que más tiempo ha entrenado
  80.     cout << "El cliente que más tiempo entrenó es el cliente " << maxClienteEnt << " con " << maxTiempoEntrenamiento << " minutos." << endl;
  81.  
  82.     // 5 - Tipos de entrenamiento no realizados por ningún cliente
  83.     cout << "Tipos de entrenamiento no realizados por ningún cliente:" << endl;
  84.     for (int j = 0; j < TIPOSENT; j++) {
  85.         bool realizoTipoEnt = false;
  86.         for (int i = 0; i < CLIENTES; i++) {
  87.             if (tiposEntPorCliente[i][j] == true) {
  88.                 realizoTipoEnt = true;
  89.             }
  90.         }
  91.         if (!realizoTipoEnt) {
  92.             cout << "Tipo de entrenamiento " << (j + 1) << " no fue realizado por ningún cliente." << endl;
  93.         }
  94.     }
  95.  
  96.     return 0;
  97. }
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement