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