35657

Untitled

Oct 8th, 2023
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct film {
  7.     char name[100]{};
  8.     char producer[100]{};
  9.     char genre[20]{};
  10.     int rating = 0;
  11. };
  12.  
  13. struct video_store {
  14.     film store[100]{};
  15.     int films_number = 0;
  16. };
  17.  
  18. void ShowAllMovies(video_store& some_store) { // вывод на консоль всех фильмов
  19.  
  20.     for (int i = 0; i < some_store.films_number; i++) {
  21.         cout << "\"" << some_store.store[i].name << "\"  \"" << some_store.store[i].producer << "\"  \"" << some_store.store[i].genre << "\"  " << some_store.store[i].rating << endl;
  22.     }
  23.     cout << endl;
  24. }
  25.  
  26.  
  27. void AddMovie(video_store& some_store, const char new_name[], const char new_producer[], const char new_genre[], const int new_rating) {
  28.     strcpy(some_store.store[some_store.films_number].name, new_name);
  29.     strcpy(some_store.store[some_store.films_number].producer, new_producer);
  30.     strcpy(some_store.store[some_store.films_number].genre, new_genre); // копируем строку в поле genre
  31.     some_store.store[some_store.films_number].rating = new_rating; // записываем значение в поле типа int
  32.     some_store.films_number++; // увеличиваем счетчик фильмов на единицу
  33. }
  34.  
  35. int main() {
  36.  
  37.     video_store my_store;
  38.  
  39.     AddMovie(my_store, "Pirates of the Caribbean", "Gore Verbinski", "fantasy", 5);
  40.     AddMovie(my_store, "Harry Potter", "Chris Columbus", "fantasy", 4);
  41.     AddMovie(my_store, "Diamond Hand", "Leonid Gaidai", "comedy", 5);
  42.     AddMovie(my_store, "Ivan Vasilyevich is changing his profession", "Leonid Gaidai", "comedy", 4);
  43.     AddMovie(my_store, "Sherlock Holmes", "Guy Ritchie", "detective", 5);
  44.     AddMovie(my_store, "Lock, Stock and Two Smoking Barrels", "Guy Ritchie", "comedy", 5);
  45.  
  46.     ShowAllMovies(my_store);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment