warriorscats

sami

Jun 2nd, 2020
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. class node {
  5.     static node *head;
  6.     node* next;
  7.     char *interpret, *melodie;
  8.  
  9. public:
  10.     node (char* = nullptr, char* = nullptr);
  11.     void display_all ();
  12.     void citireAlbum ();
  13. };
  14.  
  15. int n, index;
  16. char s[100], t[100];
  17. node* p;
  18. node* node::head = nullptr;
  19.  
  20. node::node (char* ptr, char* ptr1) {
  21.     next = nullptr, interpret = ptr, melodie = ptr1;
  22. }
  23.  
  24. inline void node::display_all () {
  25.     for (node* curr = head; curr; curr = curr->next)
  26.         std::cout << "(" << curr->interpret << ", " << curr->melodie << ") ";
  27. }
  28.  
  29. inline void node::citireAlbum () {
  30.     if (!this->head) this->head = new node (s, t);
  31.     else {
  32.         node* curr = new node (s, t);
  33.         curr->next = this->head, this->head = curr;
  34.     }
  35. }
  36.  
  37.  
  38. int main () {
  39.     std::cin >> n;
  40.     for (int i = 1; i <= n; ++ i)
  41.         std::cin >> s >> t, p->citireAlbum ();
  42.  
  43.     p->display_all ();
  44.  
  45.     return 0;
  46. }
Add Comment
Please, Sign In to add comment