Advertisement
totobac

Untitled

May 25th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4.  
  5. struct Furniture {
  6.     std::string category;
  7.     int numberOfOffers;
  8.     double minPrice;
  9.     double maxPrice;
  10.    
  11. };
  12.  
  13. void inputFurniture(Furniture* other) {
  14.     std::cin >> other->category >> other->numberOfOffers >> other->minPrice >> other->maxPrice ;
  15. }
  16.  
  17. void outputFurniture(Furniture other) {
  18.     std::cout << other.category << " " << other.numberOfOffers << " "
  19.         << other.minPrice << " " << other.maxPrice << std::endl;
  20. }
  21.  
  22. void searchCategory(Furniture arr [], int size, std::string categ) {
  23.     for (size_t i = 0; i < size; i++)
  24.     {
  25.         if (arr[i].category == categ)
  26.         {
  27.             outputFurniture(arr[i]);
  28.             break;
  29.         }
  30.     }
  31. }
  32.  
  33. int main()
  34. {
  35.     int numberOfElements;
  36.     std::cin >> numberOfElements;
  37.  
  38.     Furniture* arrayOfFurniture = new Furniture[numberOfElements];
  39.     inputFurniture(arrayOfFurniture);
  40.     searchCategory(arrayOfFurniture, numberOfElements, "home");
  41.     delete[] arrayOfFurniture;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement