Advertisement
Dotunoyesanmi

new list

Mar 6th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct Book
  6. {
  7.     string title;
  8.     Book* next;
  9. };
  10.  
  11. int main()
  12. {
  13.     Book* head = NULL;
  14.  
  15.     Book* first = new Book;
  16.     first->title = "progInCPP";
  17.     first->next = NULL;
  18.     head = first;
  19.  
  20.     Book* temp = head;
  21.     for (int i = 0; i < 5; i++)
  22.     {
  23.         while (temp->next != NULL)
  24.         {
  25.             Book* items = new Book;
  26.             first->title = "progInCPP " + i;
  27.             temp->next = items;
  28.             temp = temp->next;
  29.         }
  30.     }
  31.  
  32.     while (temp->next != NULL)
  33.     {
  34.         cout << temp->title;
  35.         temp = temp->next;
  36.     }
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement