列印環狀、含開頭空節點的雙向串列之內容

7 views
Skip to first unread message

Shyong Jian Shyu

unread,
Dec 15, 2011, 2:21:49 AM12/15/11
to sj11-data...@googlegroups.com
Dear All:
 
以下程序將環狀、含開頭空節點的雙向串列,正方向 (following next) 和反方向 (following prev) 各列印一遍。
 
void PrintDList(struct Dnode * head)
{
struct Dnode *p;
AnsiString s = "";
    for (p=head->next; p!=head; p=p->next)
        s += IntToStr(p->data)+"->";
    Form1->Memo2->Lines->Add(s+"*");

    s = "";

    for (p=head->prev; p!=head; p=p->prev)
        s += IntToStr(p->data)+"->";
    Form1->Memo2->Lines->Add(s+"*");

}

Reply all
Reply to author
Forward
0 new messages