struct linknode *subs(struct linknode *ha,struct linknode *hb)
{
struct linknode *head=NULL,*p,*q;
int a,flag;
p = ha;
//*********创建新链表所用变量*********
int i=1;
struct linknode *t,*s;
//************************************
while(p != NULL){
flag = 0; //用于表示hb里面是否有等于该节点的值
a = p->data;
q = hb;
while(q != NULL){
if(q->data == a){
flag = 1;
break;
}
q = q->next;
}
if(flag == 0){ //hb里面没有该值,所以将a保存入新的链表
if(i==1){
head = (struct linknode*)malloc(sizeof(struct linknode));
head->data = a;
head->next = NULL;
t = head;
}
else{
s = (struct linknode*)malloc(sizeof(struct linknode));
s->data = a;
s->next = NULL;
t->next = s;
t = s;
}
i++; //别漏了
}
p = p->next;
}
return head;
}
{
struct linknode *head=NULL,*p,*q;
int a,flag;
p = ha;
//*********创建新链表所用变量*********
int i=1;
struct linknode *t,*s;
//************************************
while(p != NULL){
flag = 0; //用于表示hb里面是否有等于该节点的值
a = p->data;
q = hb;
while(q != NULL){
if(q->data == a){
flag = 1;
break;
}
q = q->next;
}
if(flag == 0){ //hb里面没有该值,所以将a保存入新的链表
if(i==1){
head = (struct linknode*)malloc(sizeof(struct linknode));
head->data = a;
head->next = NULL;
t = head;
}
else{
s = (struct linknode*)malloc(sizeof(struct linknode));
s->data = a;
s->next = NULL;
t->next = s;
t = s;
}
i++; //别漏了
}
p = p->next;
}
return head;
}