Last active
August 1, 2017 01:48
-
-
Save vigack/adc14c950836903ee20e9f58b6c8a0c8 to your computer and use it in GitHub Desktop.
向指定list的尾部插入一个节点(无首节点)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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