import java.io.*;
class StackMau
{
private int maxSize;
private int[]StackArray;
private int top;
public StackMau(int s)
{
maxSize=s;
StackArray=new int[maxSize];
top=-1;
}
public void push(int j)
{
StackArray[++top]=j;
}
public int pop()
{
return StackArray[top--];
}
public int peek()
{
return StackArray[top];
}
public boolean isEmpty()
{
return(top==-1);
}
public boolean isFull()
{
return (top==maxSize-1);
}
}
class StackExample
{
public static void main(String args[])
{
StackMau theStack=new StackMau(10);
theStack.push(20);
theStack.push(40);
theStack.push(60);
theStack.push(80);
while(!theStack.isEmpty())
{
int value=theStack.pop();
System.out.print(value);
System.out.print(" ");
}
System.out.println(" ");
}
}
class StackMau
{
private int maxSize;
private int[]StackArray;
private int top;
public StackMau(int s)
{
maxSize=s;
StackArray=new int[maxSize];
top=-1;
}
public void push(int j)
{
StackArray[++top]=j;
}
public int pop()
{
return StackArray[top--];
}
public int peek()
{
return StackArray[top];
}
public boolean isEmpty()
{
return(top==-1);
}
public boolean isFull()
{
return (top==maxSize-1);
}
}
class StackExample
{
public static void main(String args[])
{
StackMau theStack=new StackMau(10);
theStack.push(20);
theStack.push(40);
theStack.push(60);
theStack.push(80);
while(!theStack.isEmpty())
{
int value=theStack.pop();
System.out.print(value);
System.out.print(" ");
}
System.out.println(" ");
}
}
No comments:
Post a Comment