C言語なら俺に聞け(入門篇) Part 11
■ このスレッドは過去ログ倉庫に格納されています
0810デフォルトの名無しさん
2007/05/04(金) 22:24:13swap(struct man *a, struct man *b)
{
struct man* a_prev = a->prev;
struct man* a_next = a->next;
struct man* b_prev = b->prev;
struct man* b_next = a->next;
a_prev->next = b;
b->next = a_next;
b_prev->next = a;
a->next = b_next;
b->prev = a_prev;
a_next->prev = b;
a->prev = b_prev;
b_next->prev = a;
}
じゃね?
加えて実際には、端にあるノードの場合の処理が必要だが。
■ このスレッドは過去ログ倉庫に格納されています