Untitled
unknown
plain_text
a year ago
524 B
8
Indexable
class Stack { static int MAX = 100000; static int[] A = new int[MAX]; static int top = -1; Stack() { top = -1; } void reset() { top = -1; } boolean isEmpty() { if (top == -1) return true; return false; } boolean isFull() { if (top == MAX - 1) return true; return false; } void push(int a) { top++; A[top] = a; } int pop() { if (!isEmpty()) { top--; return A[top + 1]; } return -1; } int peek() { return A[top]; } }
Editor is loading...
Leave a Comment