fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Node{
  5. int data;
  6. Node* pNext;
  7. };
  8.  
  9. void inputLL(Node* &pHead)
  10. {
  11. Node* cur = pHead;
  12. int x;
  13.  
  14. cout << "Please input the number: "; cin>>x;
  15. while(x != 0) {
  16. if(pHead == nullptr) {
  17. pHead = new Node;
  18. cur = pHead;
  19. } else {
  20. cur->pNext = new Node;
  21. cur = cur->pNext;
  22. }
  23.  
  24. cur->data = x;
  25. cur->pNext = nullptr;
  26. cout << "Please input the number: "; cin>>x;
  27. }
  28. }
  29.  
  30. int main() {}
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty