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(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;
- }
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- video_store my_store;
- add_movie(my_store, "Пираты Карибского моря", "Гор Вербински", "фантастика", 4);
- add_movie(my_store, "Гарри Поттер", "Крис Коламбус", "фантастика", 4);
- add_movie(my_store, "Бриллиантовая рука", "Леонид Гайдай", "комедия", 5);
- add_movie(my_store, "Иван Васильевич меняет профессию", "Леонид Гайдай", "комедия", 5);
- 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, "Пираты Карибского моря", "Гор Вербински", "фантастика", 4);
- show_all_movies(my_store);
- find_movie_name(my_store, "Шерлок Холмс");
- }
Advertisement
Add Comment
Please, Sign In to add comment