Advertisement
matheusmrf

Untitled

Jul 8th, 2020
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.84 KB | None | 0 0
  1. /*
  2.   Programa para testes de leitos por regiao
  3.   Matricula:
  4.   Nome     :
  5. */
  6.  
  7. #include <iostream>
  8.  
  9. #include <string>
  10.  
  11. #include <fstream>
  12.  
  13.  
  14. using namespace std;
  15.  
  16. class Leito {
  17.   private:
  18.     int tipo;
  19.   int ocupados;
  20.   int livres;
  21.   public:
  22.     Leito() {}
  23.   int getTipo() {
  24.     return (0);
  25.   }
  26.   void setTipo(int x) {}
  27.   int getOcupados() {
  28.     return (0);
  29.   }
  30.   void setOcupados(int x) {}
  31.   int getLivres() {
  32.     return (0);
  33.   }
  34.   void setLivres(int x) {}
  35.   string toString() {
  36.     return ("");
  37.   }
  38. };
  39.  
  40. class Teste: public Leito {
  41.   public: static void teste() {
  42.     int opcao = 0;
  43.  
  44.     do {
  45.       cout << "\nTeste" << endl;
  46.       cout << "\nOpcao: ";
  47.       cin >> opcao;
  48.       switch (opcao) {
  49.       case 0:
  50.         ;
  51.         break;
  52.       case 1:
  53.         cout << "\nResposta_1: " << endl;
  54.         break;
  55.       case 2:
  56.         cout << "\nResposta_2: " << endl;
  57.         break;
  58.       case 3:
  59.         cout << "\nResposta_3: " << endl;
  60.         break;
  61.       case 4:
  62.         cout << "\nResposta_4: " << endl;
  63.         break;
  64.       default:
  65.         ;
  66.         break;
  67.       }
  68.  
  69.     }
  70.     while (opcao != 0);
  71.     cout << endl << endl;
  72.   }
  73. };
  74.  
  75. int main(void) {
  76.  
  77.   ifstream mgrr;
  78.   ifstream especifico;
  79.   string arquivos;
  80.   int x;
  81.   int contador = 0;
  82.   int totalLeitosOcupados;
  83.   int totalLeitosLivres;
  84.   int totalLeitosOcupadosTipo1;
  85.   int totalLeitosLivresTipo1;
  86.   int totalLeitosOcupadosTipo2;
  87.   int totalLeitosLivresTipo2;
  88.   int totalLeitosOcupadosTipo3;
  89.   int totalLeitosLivresTipo3;
  90.  
  91.   mgrr.open("MG_RR.txt");
  92.   if (!mgrr) {
  93.     cout << "NÂO CONSEGUIU ABRIR O ARQUIVO";
  94.     exit(1); // terminate with error
  95.   }
  96.  
  97.   while (mgrr >> arquivos) {
  98.     especifico.open(arquivos);
  99.     if (!especifico) {
  100.       cout << "NÂO CONSEGUIU ABRIR O ARQUIVO ESPECIFICO";
  101.       exit(1); // terminate with error
  102.     }
  103.  
  104.     while (especifico >> x) {
  105.       int index = contador % 3;
  106.       if (index == 0) {
  107.         //TIPO de leito
  108.       }
  109.  
  110.       if (index == 1) {
  111.         totalLeitosOcupados++;
  112.         if (x == 1) {
  113.           totalLeitosOcupadosTipo1++;
  114.         }
  115.         if (x == 2) {
  116.           totalLeitosOcupadosTipo2++;
  117.         }
  118.         if (x == 3) {
  119.           totalLeitosOcupadosTipo3++;
  120.         }
  121.       }
  122.  
  123.       if (index == 2) {
  124.         totalLeitosLivres++;
  125.         if (x == 1) {
  126.           totalLeitosLivresTipo1;
  127.         }
  128.         if (x == 2) {
  129.           totalLeitosLivresTipo2;
  130.         }
  131.         if (x == 3) {
  132.           totalLeitosLivresTipo3;
  133.         }
  134.       }
  135.  
  136.     }
  137.  
  138.   }
  139.   //Resposta 1
  140.   cout << totalLeitosOcupados;
  141.   //Resposta2
  142.   cout << 0;
  143.   //Resposta3
  144.   cout << 0;
  145.   //Resposta4
  146.   cout << (totalLeitosLivresTipo1 + totalLeitosOcupadosTipo1) / (totalLeitosLivres + totalLeitosOcupados);
  147.  
  148.   Teste::teste();
  149.  
  150.   return (EXIT_SUCCESS);
  151. }
  152.  
  153. /*
  154.     Testes e anotacoes:
  155.  
  156. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement