fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. void makenode(int);
  4. void print();
  5. struct node
  6. {
  7. int data;
  8. struct node*next;
  9. };
  10. struct node*head;
  11. int main()
  12. {
  13. head=0;
  14. for(;;)
  15. {
  16. int x;
  17. cin>>x;
  18. if(x==0)
  19. break;
  20. else
  21. makenode(x);
  22. }
  23. print();
  24. return 0;
  25. }
  26. void makenode(int y)
  27. {
  28. struct node* temp=(struct node*)malloc(sizeof(node));
  29. temp=head;
  30. head=temp;
  31. temp->data=y;
  32. }
  33. void print()
  34. {
  35. struct node* temp1=head;
  36. while(temp1!=0)
  37. {
  38. cout<<temp1->data;
  39. temp1=temp1->next;
  40. }
  41. }
Runtime error #stdin #stdout 0s 3140KB
stdin
5 4 8 1 8 1 2 4 3 
stdout
Standard output is empty