#include <iostream>
using namespace std;
int const NONE = 0;
int const DONE = 1;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class List;
//结点
class Node{
friend class List;
public:
Node(double data, Node *prev = NULL, Node *next = NULL){
this->data = data;
this->prev = prev;
this->next = next;
}
private:
double data;
Node *prev;
Node *next;
};
//循环双链表
class List{
public:
List();
~List();
bool isEmpty(){ return length == 0; }
void addNode(double data); //添加结点
void print();
void deleteX(double x); //删除指定数值节点
private:
int length;
Node *head;
Node *end;
Node *p;
};
List::List(){
length = 0;
//头结点存结点数量
head = new Node(0);
end = head;
p = NULL;
}
List::~List(){
Node *temp = NULL;
Node *count = head->next;
head->next = NULL;
while(count){
temp = count;
循环双链表删除第一个值为x的结点
最新推荐文章于 2025-03-18 09:32:05 发布