fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Node{
  5. int data;
  6. Node* pNext;
  7. };
  8.  
  9. Node* findX(Node* pFirst, int x);
  10.  
  11. //-----------------------------------------------------//
  12.  
  13. Node* findX(Node* pFirst, int x) {
  14. Node* cur=pFirst;
  15. if(pFirst == nullptr)
  16. return nullptr;
  17. while(cur->data != x && cur->pNext != pFirst)
  18. cur = cur->pNext;
  19. if(cur->data == x)
  20. return cur;
  21. return nullptr;
  22. }
  23.  
  24. //-----------------------------------------------------//
  25.  
  26. int main() {}
Success #stdin #stdout 0.01s 5444KB
stdin
Standard input is empty
stdout
Standard output is empty