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

📄 stack.cpp

📁 主要实现了波兰式和逆波兰式的转换
💻 CPP
字号:
// STACK.cpp: implementation of the STACK class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TRANS.h"
#include "STACK.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

STACK::STACK()
{

}

STACK::~STACK()
{

}

void STACK::DestroyStack(LinkStack &s)//销毁栈
{
	LinkStack p,temp=s;
	while(temp)
	{
		p=temp;
		temp=temp->next;
		free(p);
	}
}


void STACK::InitStack(LinkStack &s)  //初始化  
{
	LinkStack p=new LNode;
	p->St=NULL;
	p->next=NULL;
	s=p;
}

void STACK::Push(LinkStack &s, char* str)//入栈
{
	LinkStack temp=new LNode;
	
	SNode*p=new SNode;
	temp->St=p;
	temp->next=s;
	s=temp;
	

   strcpy(s->St->c,str);
}



void STACK::Pop(LinkStack &s, char *str)//出栈
{
	LinkStack temp=s;
	strcpy(str,temp->St->c);
	 
	s=s->next;
}

void STACK::GetTop(LinkStack &s,char *str)
{
	strcpy(str, s->St->c);

}

⌨️ 快捷键说明

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