
1.顺序表去重
代码:
//顺序表去重
void dele(seq_p L)
{if(L==NULL){printf("入参为空,请检查\n");return;}for(int i=0;i<L->len-1;i++){for(int j=i+1;j<L->len;j++){if(L->data[i]==L->data[j]){dele_data(L,L->data[j]);j--;}}}
}
2.链表创建、节点创建,单链表头插
代码:
//创建单链表
node_p create_link_list()
{node_p H = (node_p)malloc(sizeof(node));if(H==NULL){return NULL;}H->len=0; //刚申请,长度为0H->next=NULL; //刚申请指向NULLreturn H;
}//创建节点
node_p create_node(datatype data)
{node_p new = (node_p)malloc(sizeof(node));if(new==NULL){return NULL;}new->data = data;//new->next = NULL; 可以不写return new;
}
//头插
void insert_head(node_p head,datatype data)
{node_p H=create_node(data);if(head==NULL){H=head;}else{H->next=head;head=H;}return head;
}
3.思维导图
