Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Programa para testes de leitos por regiao
- Matricula:
- Nome :
- */
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- class Leito {
- private:
- int tipo;
- int ocupados;
- int livres;
- public:
- Leito() {}
- int getTipo() {
- return (0);
- }
- void setTipo(int x) {}
- int getOcupados() {
- return (0);
- }
- void setOcupados(int x) {}
- int getLivres() {
- return (0);
- }
- void setLivres(int x) {}
- string toString() {
- return ("");
- }
- };
- class Teste: public Leito {
- public: static void teste() {
- int opcao = 0;
- do {
- cout << "\nTeste" << endl;
- cout << "\nOpcao: ";
- cin >> opcao;
- switch (opcao) {
- case 0:
- ;
- break;
- case 1:
- cout << "\nResposta_1: " << endl;
- break;
- case 2:
- cout << "\nResposta_2: " << endl;
- break;
- case 3:
- cout << "\nResposta_3: " << endl;
- break;
- case 4:
- cout << "\nResposta_4: " << endl;
- break;
- default:
- ;
- break;
- }
- }
- while (opcao != 0);
- cout << endl << endl;
- }
- };
- int main(void) {
- ifstream mgrr;
- ifstream especifico;
- string arquivos;
- int x;
- int contador = 0;
- int totalLeitosOcupados;
- int totalLeitosLivres;
- int totalLeitosOcupadosTipo1;
- int totalLeitosLivresTipo1;
- int totalLeitosOcupadosTipo2;
- int totalLeitosLivresTipo2;
- int totalLeitosOcupadosTipo3;
- int totalLeitosLivresTipo3;
- mgrr.open("MG_RR.txt");
- if (!mgrr) {
- cout << "NÂO CONSEGUIU ABRIR O ARQUIVO";
- exit(1); // terminate with error
- }
- while (mgrr >> arquivos) {
- especifico.open(arquivos);
- if (!especifico) {
- cout << "NÂO CONSEGUIU ABRIR O ARQUIVO ESPECIFICO";
- exit(1); // terminate with error
- }
- while (especifico >> x) {
- int index = contador % 3;
- if (index == 0) {
- //TIPO de leito
- }
- if (index == 1) {
- totalLeitosOcupados++;
- if (x == 1) {
- totalLeitosOcupadosTipo1++;
- }
- if (x == 2) {
- totalLeitosOcupadosTipo2++;
- }
- if (x == 3) {
- totalLeitosOcupadosTipo3++;
- }
- }
- if (index == 2) {
- totalLeitosLivres++;
- if (x == 1) {
- totalLeitosLivresTipo1;
- }
- if (x == 2) {
- totalLeitosLivresTipo2;
- }
- if (x == 3) {
- totalLeitosLivresTipo3;
- }
- }
- }
- }
- //Resposta 1
- cout << totalLeitosOcupados;
- //Resposta2
- cout << 0;
- //Resposta3
- cout << 0;
- //Resposta4
- cout << (totalLeitosLivresTipo1 + totalLeitosOcupadosTipo1) / (totalLeitosLivres + totalLeitosOcupados);
- Teste::teste();
- return (EXIT_SUCCESS);
- }
- /*
- Testes e anotacoes:
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement