voidaddNode(Node*head,intdata){Node*temp=(Node*)malloc(sizeof(Node));temp->data=data;temp->next=NULL;// find the last node of listNode*cur=head;while(cur->next!=NULL){cur=cur->next;}// add new node to rearcur->next=temp;}
voiddelNode(Node*head,intdata){if(head==NULL||head->next==NULL)return;//dont delete null or just head// speacial:delete headif(head->data==data){Node*temp=head;head=head->next;free(temp);return;}Node*cur=head;while(cur->next!=NULL&&cur->next->data!=data){cur=cur->next;}if(cur->next==NULL){return;}Node*temp=cur->next;cur->next=temp->next;free(temp);}