Facebook
From Tacky Pelican, 6 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 228
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct lista{
  6.     int value;
  7.     unique_ptr <int> next;
  8.     lista (int n){
  9.         this->value = n;
  10.         this->next = nullptr;
  11.     }
  12. };
  13.  
  14. void drukujListe(lista *head){
  15.     if(head){
  16.         if(head->next){
  17.             cout << head->value << " " << head->next.get();
  18.         }else cout << head->value;
  19.     }else cout << "";
  20. }
  21.  
  22. int main() {
  23.  
  24.     unique_ptr<lista> list = make_unique<lista>(1);
  25.  
  26.     drukujListe(list.get());
  27.  
  28.     return 0;
  29. }