typedef struct node
{
int data;
struct node *next;
}Node;
/*返回该value值在链表中的位置,没有该值将返回0*/
int searchNode(Node *head, int value)
{
int i = 1;
Node *p = head->next;
while(p)
{
if(p->data == value)
return i;
else
{
p = p->next;
i++;
}
}
return 0;
}
阅读(686) | 评论(0) | 转发(0) |