Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws Exception {
- Pilha<Integer> a = new Pilha<Integer>(4);
- a.empilhar(10);
- a.empilhar(42);
- a.empilhar(95);
- a.empilhar(78);
- int maior = Integer.MIN_VALUE;
- int menor = Integer.MAX_VALUE;
- Pilha<Integer> aux = new Pilha<Integer>(4);
- while (!a.pilhaVazia()) {
- int x = a.desempilhar();
- if (x > maior)
- maior = x;
- if (x < menor)
- menor = x;
- aux.empilhar(x);
- }
- while (!aux.pilhaVazia()) {
- a.empilhar(aux.desempilhar());
- }
- System.out.println("MAIOR: " + maior);
- System.out.println("MENOR: " + menor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement