8

 avatar
gorazd
c_cpp
a month ago
1.8 kB
2
Indexable
1kolok_OOP
#include <iostream>
#include <cstring>
#include  <iomanip>
using namespace std;

struct Laptop {
    char brand[100];
    float display;
    bool touchScreen;
    int price;
};
struct ITStore {
    char store[100];
    char location[100];
    Laptop availableLaptops[100];
    int numberOfLaptops;
};

void print(const ITStore &it_store) {
    cout<<it_store.store<<" "<<it_store.location<<endl;
    for (int i = 0; i<it_store.numberOfLaptops; i++) {
        cout<<it_store.availableLaptops[i].brand<<" "<<it_store.availableLaptops[i].display<<" "<<it_store.availableLaptops[i].price<<endl;
    }
}
void najeftina_ponuda(const ITStore *stores, int n) {
    int min = 99999;
    ITStore naj;
    for (int i = 0; i<n; i++) {
        for (int j = 0; j < stores[i].numberOfLaptops; j++) {
            if (stores[i].availableLaptops[j].price<min and stores[i].availableLaptops[j].touchScreen) {
                min = stores[i].availableLaptops[j].price;
                naj = stores[i];
            }
        }
    }
    cout<<"Najeftina ponuda ima prodavnicata: "<<endl;
    cout<<naj.store<<" "<<naj.location<<endl;
    cout<<"Najniskata cena iznesuva: "<<min<<endl;
}

int main() {
    int n;
    cin>>n; //number of it stores;
    ITStore stores[n];
    for (int i = 0; i < n; i++) {
        cin>>stores[i].store;
        cin>>stores[i].location;
        cin>>stores[i].numberOfLaptops;
        for (int j = 0; j<stores[i].numberOfLaptops; j++) {
            cin>>stores[i].availableLaptops[j].brand;
            cin>>stores[i].availableLaptops[j].display;
            cin>>stores[i].availableLaptops[j].touchScreen;
            cin>>stores[i].availableLaptops[j].price;
        }
    }
    for (int i = 0; i<n; i++) {
        print(stores[i]);
    }
    najeftina_ponuda(stores,n);

}
Editor is loading...
Leave a Comment