public class Stack { public Element head; public Stack() { this.head = null; } public Stack(String value) { this.head = new Element(value, null); } public void push(String value) { this.head = new Element(value, this.head); } public String pop() { String currentHead = this.head.value; this.head = this.head.tail; return currentHead; } private static class Element { public String value; public Element tail; public Element( String value, Element tail ) { this.value = value; this.tail = tail; } }}
Mysteriöser Algorithmus
static void move(int[] arr) { for (int i = 0; i < arr.length - 1; i++) { for (int j = 0; j < arr.length - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } }}