zoukankan      html  css  js  c++  java
  • [算法] 顺序栈的实现

    #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;
    }
    

  • 相关阅读:
    测试理论
    字符串
    类的无参方法
    类和对象
    数组
    循环结构
    选择结构
    java——面对对象
    android通知的基本用法
    Git的基本使用
  • 原文地址:https://www.cnblogs.com/robbychan/p/3787136.html
Copyright © 2011-2022 走看看