Vlad5080

Start OOP

Feb 11th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <random>
  4.  
  5. using namespace std;
  6.  
  7. struct Book {
  8.  
  9.     int id;
  10.     int pages;
  11.     float price;
  12.  
  13. };
  14.  
  15. struct library {
  16.     Book classics[3];
  17.     Book horror[3];
  18. };
  19.  
  20. int main() {
  21.     setlocale(0, "");
  22.  
  23.     Book c1 = { 1, 100, 50 };
  24.     Book c2 = { 2, 100, 50 };
  25.     Book c3 = { 3, 100, 50 };
  26.  
  27.     Book h1 = { 4, 200, 70 };
  28.     Book h2 = { 5, 300, 70 };
  29.     Book h3 = { 6, 400, 70 };
  30.  
  31.     library l1 = { {c1,c2,c3},{h1,h2,h3} };
  32.  
  33.     for (int i = 0; i < 3; i++) {
  34.  
  35.         cout << "Classics literature: " << endl;
  36.         cout << "Book: " << endl;
  37.         cout << "ID: " << l1.classics[i].id << endl;
  38.         cout << "Pages: " << l1.classics[i].pages << endl;
  39.         cout << "Price: " << l1.classics[i].price << endl;
  40.  
  41.     }
  42.     cout << "\n\n";
  43.  
  44.     for (int i = 0; i < 3; i++) {
  45.  
  46.         cout << "Horror literature: " << endl;
  47.         cout << "Book: " << endl;
  48.         cout << "ID: " << l1.horror[i].id << endl;
  49.         cout << "Pages: " << l1.horror[i].pages << endl;
  50.         cout << "Price: " << l1.horror[i].price << endl;
  51.  
  52.     }
  53.  
  54.  
  55.  
  56.     system("pause");
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment