package com.vitam.consloe;
import java.lang.*;
import java.math.*;
import java.util.*;
import java.util.Vector;
public class MyStack {
?private int top;//棧頂top;
?private int length;
?private char[] stack;//用來存儲(chǔ);
?public MyStack()
?{
??top=0;//指向棧底;
?}
?public MyStack(int n)
?{
??this();
??this.length=n;
??stack= new char[n];
??for(int i =0;i<n;i++)
??{
???stack[i]='#';
??}
?}
?public void setTop(int n)
?{
??this.top=n;
?}
?public int getTop()
?{
??return this.top;
?}
?public void setLength(int n)
?{
??this.length=n;
?}
?public int getLength()
?{
??return this.length;
?}
?public char? outStack()
?{
??char tmp='#';//
??if(top==0)
??{
???System.out.print("棧為空,沒有元素");
??}
??else
??{?
???--top;
???tmp=this.stack[top];
???this.stack[top]='#';
??}
??return tmp;
?}
?public void? pushStack(char n)
?{
?? if(top==stack.length)
?? {
??? System.out.print("棧滿,無法插入元素");
?? }
?? else
?? {
??? this.stack[top]=n;
??? top++;
?? }
?}
}