fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5.  
  6. struct node
  7. {
  8. int val;
  9. node *next;
  10. node(int val,node *next):val(val),next(next) {}
  11. };
  12.  
  13. int main()
  14. {
  15. node *lista=0;
  16. for(int i=0;i<20;++i) lista=new node(1+rand()%15,lista);
  17. for(node *i=lista;i;i=i->next) cout<<i->val<<' ';
  18. //cin.get();
  19. return 0;
  20. }
Success #stdin #stdout 0s 2860KB
stdin
Standard input is empty
stdout
2 8 7 1 2 9 5 6 8 3 2 10 13 2 11 9 11 13 2 14