Skip to content

Instantly share code, notes, and snippets.

@vigack
Last active August 1, 2017 01:48
Show Gist options
  • Save vigack/adc14c950836903ee20e9f58b6c8a0c8 to your computer and use it in GitHub Desktop.
Save vigack/adc14c950836903ee20e9f58b6c8a0c8 to your computer and use it in GitHub Desktop.
向指定list的尾部插入一个节点(无首节点)
Node* insert(Node *head,int data)
{
Node *tail;
Node *tmp;
tail = (Node *)malloc(sizeof(struct Node));
tail->data = data;
if(head == NULL){
head = tail;
}else{
tmp = head;
while(tmp->next != NULL)
tmp = tmp->next;
tmp->next = tail;
}
return head;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment