#include <iostream>
using namespace std;
class Node
{public:
intdata;
Node*nextNode, *preNode;
};
class Dlist
{
public:
Node *head,*tail, *now;
Dlist(){head = tail = NULL;}
voidinsert(int x);
voidshow();
voidremove(int y);
voidreverseShow();
};
void Dlist::insert(int x)
{
Node *newnode = newNode;
newnode->data = x;
newnode->nextNode =newnode->preNode=NULL;
if (head ==NULL)
{
head = tail = newnode;
}
else
{
tail->nextNode = newnode ;
newnode->preNode =tail;
tail = newnode;
}
}
//從頭印到尾
void Dlist::show()
{
}
//移除含y值節`點,若Y值不存在,則印出不存在
void Dlist::remove(int y)
{
};
//將串列之值,由最後元素倒著印回來
void Dlist::reverseShow()
{
};
void main()
{
Dlist aa;
aa.insert(10);
aa.insert(11);
aa.insert(12);
aa.insert(13);
aa.show();//應印出10, 11, 12, 13, 跳行
aa.remove(10);
aa.reverseShow();//應印出13, 12, 11跳行
aa.remove(13);
aa.show();//應印出11, 12, 跳行
aa.insert(15);
aa.reverseShow();//應印出15, 12, 11 跳行
system("pause");
--------------------------------------------------------------------------------
newnode->nextNode =newnode->preNode=NULL;
if (head ==NULL)
{
head = tail = newnode;
}
else
{
tail->nextNode = newnode ;
newnode->preNode =tail;
tail = newnode;
}
這一段我看不懂....有大大能說明一下嗎?
歡迎光臨 伊莉討論區 (http://www95.eyny.com/) | Powered by Discuz! |