Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
3.2 kB
14
Indexable
Never
#include <vector>
#include <iostream>
#include <string>

using namespace std;

struct District {
    string name;
    double area;
    int population;
};

struct City {
    string name;
    int population;
    District districts[100];
};

struct Apartment {
    double area;
    int floor;
    int rooms;
    string address;
    double price;
    bool hasElevator;
    District district;
    City city;
};

void printApartment(Apartment& ap) {
    cout << ap.address << ", " << ap.area << "m2, " << ap.floor;
    cout << " floor, " << ap.rooms << " rooms, " << ap.price << " euro" << endl;
}


int main() {
    District ovchaKupel { "Ovcha Kupel", 60000, 60000 };
    District manastirskiLivadi { "Manastirski livadi", 60000, 60000 };
    District kapana { "Kapana", 60000, 60000 };
    District centerPlovdiv { "Center", 60000, 60000 };
    District krasnoSelo { "Krasno Selo", 60000, 60000 };
    
    City sofia { "Sofia", 1000000, { ovchaKupel, manastirskiLivadi, krasnoSelo } };
    City plovdiv { "Plovdiv", 450000, { kapana, centerPlovdiv } };
    
    Apartment apartments[5];
    
    apartments[0].address = "st. Narodno Horo 84, Ovcha Kupel, Sofia";
    apartments[0].area = 80;
    apartments[0].floor = 2;
    apartments[0].rooms = 3;
    apartments[0].price = 250000;
    apartments[0].hasElevator = true;
    apartments[0].district = ovchaKupel;
    apartments[0].city = sofia;
    
    apartments[1].address = "st. Golemo Malko 23, Manastirski livadi, Sofia";
    apartments[1].area = 90;
    apartments[1].floor = 11;
    apartments[1].rooms = 3;
    apartments[1].price = 600000;
    apartments[1].hasElevator = true;
    apartments[1].district = manastirskiLivadi;
    apartments[1].city = sofia;
    
    apartments[2].address = "st. Paco Rabana 3, Kapana, Plovdiv";
    apartments[2].area = 45;
    apartments[2].floor = 1;
    apartments[2].rooms = 1;
    apartments[2].price = 50000;
    apartments[2].hasElevator = false;
    apartments[2].district = kapana;
    apartments[2].city = plovdiv;
    
    apartments[3].address = "st. Strashen 5, Center, Plovdiv";
    apartments[3].area = 30;
    apartments[3].floor = 2;
    apartments[3].rooms = 1;
    apartments[3].price = 75000;
    apartments[3].hasElevator = false;
    apartments[3].district = centerPlovdiv;
    apartments[3].city = plovdiv;
    
    apartments[4].address = "st. White Holes, Krasno Selo, Sofia";
    apartments[4].area = 150;
    apartments[4].floor = 2;
    apartments[4].rooms = 4;
    apartments[4].price = 1000000;
    apartments[4].hasElevator = true;
    apartments[4].district = krasnoSelo;
    apartments[4].city = sofia;
    
    
    string myCity, myDistrict;
    int myFloor, myRooms;
    double myBudget;

    getline(cin, myCity);
    getline(cin, myDistrict);
    cin >> myFloor >> myRooms >> myBudget;
    
    for (int i = 0; i < 5; i++) {
        if ((myCity == apartments[i].city.name || myCity == "No type") && 
            (myDistrict == apartments[i].district.name || myDistrict == "No type")) {
            if (myRooms >= apartments[i].rooms &&
                        myBudget >= apartments[i].price) {
                printApartment(apartments[i]);       
            }
        }
    }
    
    return 0;
}
Leave a Comment