[算法] 链栈的实现

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <iterator>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <climits>
#include <cassert>
#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;
}

posted @ 2013-01-29 21:57  小尼人00  阅读(132)  评论(0编辑  收藏  举报