假設有3個指標:
head指向linked list頭,
cur指向linked list頭,
nextprocess指向null.
if ( cur->next->next != null ) {
cur->next->next = nextprocess;
// 將第三個node先用nextprocess指著
cur->next->next = cur;
head = cur->next;
cur->next = null;
do {
cur = nextprocess;
if ( nextprocess->next != null ) {
nextprocess = nextprocess->next;
// 檢查是否後面還有node
} // if
cur->next = head;
head = cur;
} while ( nextprocess != null )
} // if
else {
//此linked list可能只有0-2個node
} // else
2011年4月30日 星期六
2011年3月17日 星期四
2011年3月16日 星期三
訂閱:
文章 (Atom)