You are on page 1of 2

#include <iostream>

#include <vector>
using namespace std;
class Hotel
{
public:
char* denumire;
unsigned int cod_hotel;
unsigned int numar_stele;
float pret_camera;
unsigned int nr_camere;
unsigned int nr_camere_ocupate;
void afisare()
{
cout << this->cod_hotel << endl << this->denumire << endl;
}
};
class Resort
{
public:
char* nume;
int nr_hotel;
Hotel *hotel;
};
Hotel init(char* den, unsigned int ch, unsigned int nrS, float pret, unsigned in
t nrC, unsigned int nrCocup)
{
Hotel h;
h.denumire = new char[strlen(den) + 1];
strcpy(h.denumire, den);
h.cod_hotel = ch;
h.numar_stele = nrS;
h.pret_camera = pret;
h.nr_camere = nrC;
h.nr_camere_ocupate = nrCocup;
return h;
}
Resort initializare(char* nume, int nr, Hotel* hot)
{
Resort r;
r.nume = new char[strlen(nume) + 1];
strcpy(r.nume, nume);
r.nr_hotel = nr;
r.hotel = new Hotel[nr];
for (int i = 0; i < nr; i++)
{
r.hotel[i] = hot[i];
}
return r;
}
float grad(int cod, Resort r)
{
float gradOc;
for (int i = 0; i < r.nr_hotel; i++)

{
if (cod == r.hotel[i].cod_hotel)
{
//gradOc = (r.hotel[i].nr_camere_ocupate / r.hotel[i].nr
_camere);
gradOc = r.hotel[i].nr_camere - r.hotel[i].nr_camere_ocu
pate;
}
}
return gradOc;
}
Hotel* venit(Resort r, int z, int x)
{
int venit;
Hotel* h;
h = new Hotel[100];
int nr = 0;
for (int i = 0; i < r.nr_hotel; i++)
{
venit = r.hotel[i].nr_camere_ocupate * r.hotel[i].pret_camera;
if ((venit > z) && (venit < x))
{
nr++;
for (int j = 0; j < nr; j++)
{
h[j] = r.hotel[i];
}
}
}
return h;
}

void main()
{
Hotel h,m;
h = init("Iris", 1, 3, 1000, 500, 100);
m = init("asdfsd", 2, 5, 2000, 700, 400);
h.afisare();
Resort r;
Hotel *j = &h;
r = initializare("Alo", 1, j);
float gg = grad(h.cod_hotel, r);
cout << gg;
Hotel* vector = venit(r, 2000, 5000000);
}

You might also like