Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- using namespace std;
- struct film {
- char name[40];
- char producer[40];
- char genre[40];
- int rating;
- };
- struct video_store {
- film store[100];
- int films_number = 0;
- };
- void show_all_movies(const video_store& some_store) {
- for (int i = 0; i < some_store.films_number; ++i) {
- cout << '\"' << some_store.store[i].name << "\", продюсер: " << some_store.store[i].producer << ", " << some_store.store[i].genre << ", рейтинг " << some_store.store[i].rating << endl;
- }
- cout << endl;
- }
- void add_movie(video_store& some_store, const char* name, const char* producer, const char* genre, const int rating) {
- if (some_store.films_number == 100) {
- cout << "Фильм не может быть добавлен" << endl;
- return;
- }
- strcpy(some_store.store[some_store.films_number].name, name);
- strcpy(some_store.store[some_store.films_number].producer, producer);
- strcpy(some_store.store[some_store.films_number].genre, genre);
- some_store.store[some_store.films_number].rating = rating;
- some_store.films_number++;
- }
- void del_movie(video_store& some_store, const char* name) {
- for (int i = 0; i < some_store.films_number; i++) {
- if (!strcmp(some_store.store[i].name, name)) {
- for (int j = i; j < some_store.films_number - 1; j++) {
- some_store.store[j] = some_store.store[j + 1];
- }
- some_store.films_number--;
- }
- }
- }
- void find_movie_name(const video_store& some_store, const char* name) {
- for (int i = 0; i < some_store.films_number; i++) {
- if (!strcmp(some_store.store[i].name, name)) {
- cout << '\"' << some_store.store[i].name << "\", продюсер: " << some_store.store[i].producer << ", " << some_store.store[i].genre << ", рейтинг " << some_store.store[i].rating << endl;
- }
- }
- cout << endl;
- }
- void find_movie_producer(video_store& some_store, const char* producer) {
- for (int i = 0; i < some_store.films_number; i++) {
- if (!strcmp(some_store.store[i].producer, producer)) {
- cout << '\"' << some_store.store[i].name << "\", продюсер: " << some_store.store[i].producer << ", " << some_store.store[i].genre << ", рейтинг " << some_store.store[i].rating << endl;
- }
- }
- cout << endl;
- }
- void find_movie_genre(video_store& some_store, const char* genre) {
- for (int i = 0; i < some_store.films_number; i++) {
- if (!strcmp(some_store.store[i].genre, genre)) {
- cout << '\"' << some_store.store[i].name << "\", продюсер: " << some_store.store[i].producer << ", " << some_store.store[i].genre << ", рейтинг " << some_store.store[i].rating << endl;
- }
- }
- cout << endl;
- }
- void find_movie_most_popular(video_store& some_store, const char genre[]) {
- int index = -1;
- int rating = 0;
- for (int i = 0; i < some_store.films_number; i++) {
- if (!strcmp(some_store.store[i].genre, genre)) {
- if (some_store.store[i].rating > rating) {
- index = i;
- rating = some_store.store[i].rating;
- }
- }
- }
- if (index != -1) {
- cout << '\"' << some_store.store[index].name << "\", продюсер: " << some_store.store[index].producer << ", " << some_store.store[index].genre << ", рейтинг " << some_store.store[index].rating << endl;
- }
- cout << endl;
- }
- int main() {
- setlocale(LC_ALL, "ru");
- video_store my_store;
- add_movie(my_store, "Пираты Карибского моря", "Гор Вербински", "фантастика", 5);
- add_movie(my_store, "Гарри Поттер", "Крис Коламбус", "фантастика", 4);
- add_movie(my_store, "Бриллиантовая рука", "Леонид Гайдай", "комедия", 5);
- add_movie(my_store, "Иван Васильевич меняет профессию", "Леонид Гайдай", "комедия", 4);
- add_movie(my_store, "Шерлок Холмс", "Гай Ричи", "детектив", 5);
- add_movie(my_store, "Карты, деньги, два ствола", "Гай Ричи", "комедия", 5);
- show_all_movies(my_store);
- del_movie(my_store, "Пираты Карибского моря");
- show_all_movies(my_store);
- add_movie(my_store, "Пираты Карибского моря", "Гор Вербински", "фантастика", 5);
- find_movie_name(my_store, "Бриллиантовая рука");
- find_movie_producer(my_store, "Гай Ричи");
- find_movie_genre(my_store, "фантастика");
- find_movie_most_popular(my_store, "фантастика");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement