Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct film {
- char name[100]{};
- char producer[100]{};
- char genre[20]{};
- int rating = 0;
- };
- struct video_store {
- film store[100]{};
- int films_number = 0;
- };
- void ShowAllMovies(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 AddMovie(video_store& some_store, const char new_name[], const char new_producer[], const char new_genre[], const int new_rating) {
- strcpy(some_store.store[some_store.films_number].name, new_name);
- strcpy(some_store.store[some_store.films_number].producer, new_producer);
- strcpy(some_store.store[some_store.films_number].genre, new_genre); // копируем строку в поле genre
- some_store.store[some_store.films_number].rating = new_rating; // записываем значение в поле типа int
- some_store.films_number++; // увеличиваем счетчик фильмов на единицу
- }
- int main() {
- video_store my_store;
- AddMovie(my_store, "Pirates of the Caribbean", "Gore Verbinski", "fantasy", 5);
- AddMovie(my_store, "Harry Potter", "Chris Columbus", "fantasy", 4);
- AddMovie(my_store, "Diamond Hand", "Leonid Gaidai", "comedy", 5);
- AddMovie(my_store, "Ivan Vasilyevich is changing his profession", "Leonid Gaidai", "comedy", 4);
- AddMovie(my_store, "Sherlock Holmes", "Guy Ritchie", "detective", 5);
- AddMovie(my_store, "Lock, Stock and Two Smoking Barrels", "Guy Ritchie", "comedy", 5);
- ShowAllMovies(my_store);
- }
Advertisement
Add Comment
Please, Sign In to add comment