em dùng như dưới đó anh
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *next;
}node;
node *init(node *list,int x)
{
node *p=(node*)malloc(sizeof(node));
p->next=list;
p->data=x;
}
node* xoaNodeChan(node *list)
{
node *tempF =(node*)malloc(sizeof(node));
tempF=NULL;
node *temp =(node*)malloc(sizeof(node));
temp->next = list;
while(temp->next != NULL)
{
if (temp->next->data % 2 == 0) {
node *tempDel=(node*)malloc(sizeof(node));
tempDel = temp->next;
temp->next = temp->next->next;
free(tempDel);
} else {
if (tempF == NULL)
{
tempF = temp->next;
}
temp = temp->next;
}
}
return tempF;
}
void printfll(node *list)
{
while(list!=NULL)
{
printf("%d :",list->data);
list=list->next;}
printf("\n");
}
int main()
{
node *a,*b,*c,*d,*e,*f;
a=init(NULL,50);
b=init(a,4);
c=init(b,3);
d=init(c,2);
e=init(d,10);
f=init(e,2);
printfll(f);
xoaNodeChan(f);
printfll(f);
getch();
return 1;
}