#include <iostream>
#include <string>
using namespace std;
struct BorrowedBook {
string title;
string author;
void printStructureData() {
cout << "Title: " << title << ", Author: " << author << endl;
}
};
struct LibraryMember {
string name;
int id;
BorrowedBook book;
void printStructureData() {
cout << "Member Name: " << name << ", Member ID: " << id << endl;
book.printStructureData();
}
};
bool compareParameters(const LibraryMember &member1, const LibraryMember &member2) {
return member1.name == member2.name && member1.id == member2.id;
}
void sortMembers(LibraryMember* members, int size) {
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (members[j].id > members[j + 1].id) {
LibraryMember temp = members[j];
members[j] = members[j + 1];
members[j + 1] = temp;
}
}
}
}
int main() {
const int SIZE = 2;
LibraryMember members[SIZE];
members[0].name = "Sulu";
members[0].id = 2;
members[0].book.title = "Sad";
members[0].book.author = "Zhambyl";
members[1].name = "Beka";
members[1].id = 1;
members[1].book.title = "Hello";
members[1].book.author = "Abay";
for (int i = 0; i < SIZE; i++) {
members[i].printStructureData();
cout << endl;
}
bool areEqual = compareParameters(members[0], members[1]);
cout << "Are the two members equal? " << (areEqual ? "Yes" : "No") << endl;
sortMembers(members, SIZE);
cout << "\nSorted Members by ID:\n";
for (int i = 0; i < SIZE; i++) {
members[i].printStructureData();
cout << endl;
}
return 0;
}