#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
// Define a struct to hold book information
struct Book {
std:: string title;
std:: string author;
std:: string isbn;
} ;
// Function to print the books in a tabular format
void printBooks( const std:: vector < Book> & books) {
// Print the header
std:: cout << std:: left << std:: setw ( 30 ) << "Title"
<< std:: setw ( 30 ) << "Author"
<< std:: setw ( 20 ) << "ISBN" << std:: endl ;
std:: cout << std:: string ( 80 , '-' ) << std:: endl ;
// Print each book's details
for ( const auto & book : books) {
std:: cout << std:: left << std:: setw ( 30 ) << book.title
<< std:: setw ( 30 ) << book.author
<< std:: setw ( 20 ) << book.isbn << std:: endl ;
}
}
int main( ) {
// Create a vector of books
std:: vector < Book> books = {
{ "The Great Gatsby" , "F. Scott Fitzgerald" , "9780743273565" } ,
{ "1984" , "George Orwell" , "9780451524935" } ,
{ "To Kill a Mockingbird" , "Harper Lee" , "9780060935467" }
} ;
// Print the books
printBooks( books) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KCi8vIERlZmluZSBhIHN0cnVjdCB0byBob2xkIGJvb2sgaW5mb3JtYXRpb24Kc3RydWN0IEJvb2sgewogICAgc3RkOjpzdHJpbmcgdGl0bGU7CiAgICBzdGQ6OnN0cmluZyBhdXRob3I7CiAgICBzdGQ6OnN0cmluZyBpc2JuOwp9OwoKLy8gRnVuY3Rpb24gdG8gcHJpbnQgdGhlIGJvb2tzIGluIGEgdGFidWxhciBmb3JtYXQKdm9pZCBwcmludEJvb2tzKGNvbnN0IHN0ZDo6dmVjdG9yPEJvb2s+JiBib29rcykgewogICAgLy8gUHJpbnQgdGhlIGhlYWRlcgogICAgc3RkOjpjb3V0IDw8IHN0ZDo6bGVmdCA8PCBzdGQ6OnNldHcoMzApIDw8ICJUaXRsZSIKICAgICAgICAgICAgICA8PCBzdGQ6OnNldHcoMzApIDw8ICJBdXRob3Ii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