15,440
社区成员
发帖
与我相关
我的任务
分享
class ListNode
{
public:
int key;
ListNode *next;
ListNode():next(NULL){}
ListNode(int x):key(x),next(NULL){}
~ListNode(){};//mark
};
class LinearList
{
private:
int size;
ListNode *head;
public:
LinearList(void) ;
~LinearList(void);
bool insert(int x, int pos);
bool remove(int &x, int pos);
int element(int pos) const;
int search(int x) const;
int length() const;
ListNode* find(int i)const; //mark
};
ListNode* LinearList::find(int i) const //mark
{
ListNode *node = head;
int x = 0;
while ((x++ <i)&&(node!=NULL))
node = node->next;
return node;
}