Skip to content

Instantly share code, notes, and snippets.

@KevinKu
Created February 3, 2016 07:47
Show Gist options
  • Save KevinKu/a69b894740324eddd1f2 to your computer and use it in GitHub Desktop.
Save KevinKu/a69b894740324eddd1f2 to your computer and use it in GitHub Desktop.
pre_node_1->next = node_2;
/*
先node_1或node_2沒有差別 這邊我選先把node_1的位置換成node_2
所以node_1前一個node的next的value要是node_2的address
*/
tmp_node = node_2->next
/*
由於接下來要把lined list串起來(讓node_2的next是node_1的next) 可是node_2的next待會串node_1還要用 所以要先保留
*/
node_2->next = node_1->next;
/*這邊node_2就成功替代node_1的位置*/
pre_node_2->next = node_1;
node_1->next = tmp_node
/*以上兩行就是node_1代替node_2的位置*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment