걍/// 자료 구조 공부 함서..
한번 올려 봅니다..
배열을 이용한 스택구현.. ㅡㅡㅋ
이제 시작.?
다음은 연결 리스트를 이용한.. 스택구현.. ;;
점심시간이 끝나갑니다..
어여 ~ 날코딩 하러;;
------------------------------------------------------------------------------
내 스스로가 내 자신을 하찮은 사람으로 만들어 버렷다...
------------------------------------------------------------------------------
class StackArray
{
public int maxSize;
public int top;
public int[] sArray;
public StackArray()
{
this.maxSize = 10;
top = -1;
sArray = new int[maxSize];
}
public StackArray(int size)
{
this.maxSize = size;
top = -1;
sArray = new int[maxSize];
}
public boolean push(int iData)
{
if(isFull())
{
System.out.println("This Stack ... Size.... Full");
return false;
}
else
{
sArray[++top] = iData;
return true;
}
}
public boolean pop(int[] iArray)
{
if(isEmpty())
{
System.out.println("This Stack..... Empty");
return false;
}
else
{
iArray[0] = sArray[top--];
return true;
}
}
public boolean peek(int[] iArray)
{
if(isEmpty())
{
System.out.println("This Stack ..... Empty");
return false;
}
else
{
iArray[0] = sArray[top];
return true;
}
}
public boolean isFull()
{
return (maxSize - 1) == top?true:false;
}
public boolean isEmpty()
{
return top == -1 ? true:false;
}
}




