fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip> // For formatting output
  5.  
  6. struct Book {
  7. std::string title;
  8. std::string author;
  9. std::string isbn;
  10. };
  11.  
  12. int main() {
  13. // Sample book data (you can replace this with user input or reading from a file)
  14. std::vector<Book> books = {
  15. {"The Lord of the Rings", "J.R.R. Tolkien", "978-0618260264"},
  16. {"Pride and Prejudice", "Jane Austen", "978-0141439518"},
  17. {"1984", "George Orwell", "978-0451524935"}
  18. };
  19.  
  20. // Print header row
  21. std::cout << std::setw(30) << "Title"
  22. << std::setw(25) << "Author"
  23. << std::setw(15) << "ISBN" << std::endl;
  24. std::cout << std::string(70, '-') << std::endl; // Separator line
  25.  
  26. // Print book data in rows
  27. for (const auto& book : books) {
  28. std::cout << std::setw(30) << book.title
  29. << std::setw(25) << book.author
  30. << std::setw(15) << book.isbn << std::endl;
  31. }
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
                         Title                   Author           ISBN
----------------------------------------------------------------------
         The Lord of the Rings           J.R.R. Tolkien 978-0618260264
           Pride and Prejudice              Jane Austen 978-0141439518
                          1984            George Orwell 978-0451524935