首页 > 代码库 > Infix to posfix 自己写stack,没有()

Infix to posfix 自己写stack,没有()

#include<iostream>#include<string>using namespace std;template<typename Type>struct Node{	Type data;	Node<Type>*next;};template<typename Type>class Stack{private:	Node<Type>*head;public:	//构造函数	Stack()	{		head = new Node<Type>;		head->next = NULL;	}	//析构函数	 	~Stack()	{		delete head;	}	//判空	bool isEmpty()	{		if (head->next == NULL)			return true;		return false;	}	//入栈	void push(Type item)	{		Node<Type>*p = new Node<Type>;		p->data = http://www.mamicode.com/item;"";	while (num.top() != ‘#‘)	{		s1 = s1 + num.top();		num.pop();	}	for (int i = 0; i<s1.size() / 2; i++)	{		char temp = s1[i];		s1[i] = s1[s1.size() - 1 - i];		s1[s1.size() - 1 - i] = temp;	}	cout << s1 << endl;	return 0;}

  

Infix to posfix 自己写stack,没有()