Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct book {
- char title[40];
- char author[40];
- char publisher[40];
- char genre[40];
- };
- void print_book(const book* arr, const int size) {
- for (int i = 0; i < size; i++) {
- cout << arr[i].title << ", автор - " << arr[i].author << ", издательство " << arr[i].publisher << ", жанр - " << arr[i].genre << endl;
- }
- }
- void find_book_title(const book* arr, const int size, const char* title) {
- for (int i = 0; i < size; i++) {
- if (!strcmp(title, arr[i].title)) {
- cout << arr[i].title << ", автор - " << arr[i].author << ", издательство " << arr[i].publisher << ", жанр - " << arr[i].genre << endl;
- }
- }
- }
- void find_book_author(const book* arr, const int size, const char* author) {
- for (int i = 0; i < size; i++) {
- if (!strcmp(author, arr[i].author)) {
- cout << arr[i].title << ", автор - " << arr[i].author << ", издательство " << arr[i].publisher << ", жанр - " << arr[i].genre << endl;
- }
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- const int size = 5;
- book library[size];
- library[0] = { "Мастер и Маргарита", "Михаил Булгаков", "Лабиринт", "роман" };
- library[1] = { "Собачье сердце", "Михаил Булгаков", "Питер", "повесть" };
- library[2] = { "Палата № 6", "Антон Чехов", "Питер", "повесть" };
- library[3] = { "Война и мир", "Лев Толстой", "АСТ", "роман" };
- library[4] = { "Обломов", "Иван Гончаров", "Лабиринт", "роман" };
- print_book(library, size);
- cout << endl << endl;
- find_book_title(library, size, "Палата № 6");
- cout << endl << endl;
- find_book_author(library, size, "Михаил Булгаков");
- }
Advertisement
Add Comment
Please, Sign In to add comment