fork download
  1. #include <iostream>
  2. using namespace std;
  3. struct node{
  4. int data;
  5. node *next;
  6. }*head, *temp, *temp1;
  7. int main() {
  8. int d;
  9. char ch;
  10. while(true)
  11. {
  12. cin>>d;
  13. if(head==NULL)
  14. {
  15. temp=new node;
  16. temp->data=d;
  17. head->next=temp;
  18. }
  19. else
  20. {
  21. temp = head;
  22. while(temp->next != NULL)
  23. temp=temp->next;
  24. temp1->data=d;
  25. temp->next=temp1;
  26. }
  27. cout<<"Do you want to insert more? (Y/N)\n";
  28. cin>>ch;
  29. if(ch=='N')
  30. {
  31. temp=head;
  32. while(temp->next!=NULL)
  33. {
  34. cout<<temp->data;
  35. temp=temp->next;
  36. }
  37. break;
  38. }
  39. }
  40. return 0;
  41. }
  42.  
Runtime error #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty