⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkedstack.cpp

📁 背包问题的解决
💻 CPP
字号:
#include "linkedstack.h"
#include "Node.h"
#include <iostream>

using namespace std;

linkedstack::~linkedstack(){
	Node *next;
	while(top){
		next=top->link;
		delete top;
		top=next;
	}
}

bool linkedstack::isfull()const
{
	try{Node *p=new Node;
		delete p;
		return false;
		}
	catch(...){return true;}
}

int linkedstack::Top()const
{
	if(isempty())cout<<"the stack is empty!"<<endl;
	return top->data;
}

linkedstack &linkedstack::Add(const int &x,int y)
{
	Node *p= new Node;
	p->data=x;
	p->sign=y;
	p->link=top;
	top=p;
	return *this;
}

linkedstack &linkedstack::Delete(int &x)
{
//cout<<"the stack is empty!"<<endl;
	if(!isempty())
	{
		x=top->data;
		Node *p=top;
		top=top->link;
		delete p;
		
	}
	return *this;
}
linkedstack ::last(){
if(!(isempty()))return top->sign;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -