[算法] 链栈的实现

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define BUG puts("here!!!");
/* linkStack C++ */
using namespace std;
struct Node {
	char value;
	Node* next;
};
bool push(Node* top, char x) {
	Node* temp;
	temp = new Node();
	if(temp == NULL) return false;
	temp->value = x;
	temp->next = top->next;
	top->next = temp;
	return true;
}
bool pop(Node* top) {
	Node* temp = top->next;
	if(temp == NULL) return false;
	top->next = temp->next;
	delete temp;
	return true;
}
char getTop(Node* top) {
	if(top->next != NULL) return top->next->value;
	return '#';
}
int main() {
	return 0;
}

你可能感兴趣的:([算法] 链栈的实现)