package com.hephec.ds;
public class SequenceStack {
public String[] stack;
//字符串栈
public int top;
//栈顶指针
public final int MAXSIZE=20;
//初始化大小
public SequenceStack(){
stack=new String[MAXSIZE];
int top=-1;
}
public void push(String str){
if(top==MAXSIZE-1){
System.out.println("栈满!");
}
else{
stack[++top]=str;
}
}
public String pop(){
if(top>=0){
return stack[top--];
}else{
return null;
}
}
}
时间: 2024-10-13 02:36:21