Другие языки программирования и технологии

Помогите с структурой на с++

Вот структура видеомагазина. Как реализовать поиск по структуре: ???
■ Поиск по названию
■ Поиск по жанру
■ Поиск по режиссеру

#include iostream
using namespace std;

//фильмы
struct Film
{
char movie[50];
char producer[50];
char genre[50];
float rating;
float price;
};

//Надписи
void inscription(Film pat)
{
cout << "\Title\t: " << pat.movie;
cout << "\nProd\t: " << pat.producer;
cout << "\nGenre\t: " << pat.genre;
cout << "\nRating\t: " << pat.rating;
cout << "\nPrice\t: " << pat.price << endl;
cout << endl;
}

int main()
{
setlocale(LC_ALL, "rus");

/*1.Создать структуру ВИДЕОМАГАЗИН*/

cout << "\t\tКиноПоиск" << endl;
const int length = 8;

Film kinopoisk[length]
{
//{ "\tФильм 1\n" },
{ "1) Avengers", "K.Feige", "fantasy", 9.5, 120 },
{ "2) Fast and furious", "V.Diesel","action", 9.2, 99.5 },
{ "3) End of time", "C.Hellsgord", "drama", 8.2, 70 },
{ "4) Angry Birds", "T.Van Orman", "cartoons", 8.5, 110 },
{ "5) No Man's Land", "M.Lyons", "action", 7.5, 74.3 },
{ "6) Scooby-Doo", "E.Spaulding", "cartoons", 9.2, 87.8 },
{ "7) Arctic Apocalypse", "J.Condelic", "fantasy", 6.3, 96 },
{ "8) The Death of Dick Long", "D.Scheinert", "drama", 6.7, 100 },
};

for (int i = 0; i < length; i++)
inscription(kinopoisk[i]);

}
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
struct Film {
string title;
string producer;
string genre;
float rating;
float price;
Film() : rating(0), price(0) {}
Film(string title, string producer, string genre, float rating, float price) : title(title), producer(producer), genre(genre), rating(rating), price(price) {}
friend ostream& operator<<(ostream& out, const Film& film) {
out << fixed << film.title << ". " << film.producer << ", " << film.genre << ". =" << setprecision(1) << film.rating << ", $" << setprecision(2) << film.price;
return out;
}
};
class FilmList {
public:
void add(const Film& film) { films_.push_back(film); }
void add(Film&& film) { films_.emplace_back(film); }
void show_all()const {
auto n = 0U;
for (auto& film : films_) cout << ++n << ") " << film << '\n';
}
void show_title(const string& title)const {
auto n = 0U;
for (auto& film : films_) if (film.title == title) cout << ++n << ") " << film << '\n';
}
void show_producer(const string& producer)const {
auto n = 0U;
for (auto& film : films_) if (film.producer == producer) cout << ++n << ") " << film << '\n';
}
void show_genre(const string& genre)const {
auto n = 0U;
for (auto& film : films_) if (film.genre == genre) cout << ++n << ") " << film << '\n';
}
private:
vector<Film> films_;
};
int main() {
FilmList flist;
flist.add(Film("Avengers", "K.Feige", "fantasy", 9.5f, 120.0f));
flist.add(Film("Fast and furious", "V.Diesel", "action", 9.2f, 99.5f));
flist.add(Film("End of time", "C.Hellsgord", "drama", 8.2f, 70.0f));
flist.add(Film("Angry Birds", "T.Van Orman", "cartoons", 8.5f, 110.0f));
flist.add(Film("No Man's Land", "M.Lyons", "action", 7.5f, 74.3f));
flist.add(Film("Scooby-Doo", "E.Spaulding", "cartoons", 9.2f, 87.8f));
flist.add(Film("Arctic Apocalypse", "J.Condelic", "fantasy", 6.3f, 96.0f));
flist.add(Film("The Death of Dick Long", "D.Scheinert", "drama", 6.7f, 100.0f));
cout << "\t\t\tAll:\n";
flist.show_all();
cout << "\n\t\t\tTitle:\n";
flist.show_title("Arctic Apocalypse");
cout << "\n\t\t\tProducer:\n";
flist.show_producer("V.Diesel");
cout << "\n\t\t\tGenre:\n";
flist.show_genre("action");
cout.put('\n');
system("pause");
}
Максим Maksim
Максим Maksim
79 195
Лучший ответ