学完C语言有好长时间了,我觉得应该把C中一些常用的函数总结一下,这即是对知识的恐固,也能在其中发现自己的不足.
以下代码实现在链表中插入结点功能:
struct employeeData *insert(struct employeeData *head, struct employeeData *new, int m)
{
int i;
struct employeeData *ptr;
ptr = head;
if (m == 1)
{new->next = head;head = new;return (head);}
for (i = 1;i < m-1; i++)
{
ptr = ptr->next;
if (ptr->next == NULL)
{ptr->next = new;new->next = NULL;return(head);}
}
new->next = ptr->next;
ptr->next = new;
return (head);
}
阅读(1310) | 评论(0) | 转发(0) |