Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- struct Furniture {
- std::string category;
- int numberOfOffers;
- double minPrice;
- double maxPrice;
- };
- void inputFurniture(Furniture* other) {
- std::cin >> other->category >> other->numberOfOffers >> other->minPrice >> other->maxPrice ;
- }
- void outputFurniture(Furniture other) {
- std::cout << other.category << " " << other.numberOfOffers << " "
- << other.minPrice << " " << other.maxPrice << std::endl;
- }
- void searchCategory(Furniture arr [], int size, std::string categ) {
- for (size_t i = 0; i < size; i++)
- {
- if (arr[i].category == categ)
- {
- outputFurniture(arr[i]);
- break;
- }
- }
- }
- int main()
- {
- int numberOfElements;
- std::cin >> numberOfElements;
- Furniture* arrayOfFurniture = new Furniture[numberOfElements];
- inputFurniture(arrayOfFurniture);
- searchCategory(arrayOfFurniture, numberOfElements, "home");
- delete[] arrayOfFurniture;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement