数据结构课后实验源代码.docxVIP

  • 1
  • 0
  • 约3.27千字
  • 约 6页
  • 2023-12-25 发布于浙江
  • 举报

数据结构课后实验源代码

以下是一个使用C++语言实现的链表数据结构的代码示例:

```cpp

#includeiostream

structNode{

intdata;

Node*next;

Node(intvalue){

data=value;

next=nullptr;

}

};

classLinkedList{

private:

Node*head;

Node*tail;

intsize;

public:

LinkedList(){

head=nullptr;

tail=nullptr;

size=0;

}

//在链表末尾添加一个新节点

voidappend(intvalue){

Node*newNode=newNode(value);

if(head==nullptr){

head=newNode;

tail=newNode;

}else{

tail-next=newNode;

文档评论(0)

1亿VIP精品文档

相关文档