#include <iostream>
using namespace std;
struct books {
char name[40];
int year;
};
int main() {
size_t dimension;
printf("Enter the dimension of books array: ");
cin >> dimension;
struct books book[dimension];
int query;
for (int i = 0; i < dimension; ++i) {
cout << "Enter name" << endl;
cin >> book[i].name;
cout << "Enter year" << endl;
cin >> book[i].year;
}
cout << "Entered array:" << endl;
for (int i = 0; i < dimension; ++i) {
cout << i << " - " << book[i].name << " - " << book[i].year << endl;
}
cout << "Enter the year of the book you want to search." << endl;
cin >> query;
for (int i = 0; i < dimension; ++i) {
if (book[i].year == query) {
cout << "Book named " << query << " found." << endl;
cout << "Name: " << book[i].name << endl << "Year: " << book[i].year << endl;
break;
}
}
return 0;
}