[算法] 顺序栈的实现

#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!!!");

using namespace std;
const int N = 5;
struct Node {
	int top;
	char elem[N];
};
void initStack(Node* S) {
	S->top = -1;
}
bool isEmpty(Node* S) {
	if(S->top == -1) return true;
	return false;
}
bool isFull(Node* S) {
	if(S->top  == N-1) return true;
	return false;
}
bool push(char value, Node* S) {
	if(S->top == N-1) return false;
	S->top++;
	S->elem[S->top] = value;
	return true;
}
bool pop(Node* S) {
	if(S->top == -1) return false;
	S->top--;
	return true;
}
char getTop(Node* S) {
	if(S->top > -1) return S->elem[S->top];
	return '#';
}
int main() {
	return 0;
}

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