first commit

This commit is contained in:
Jeena Paradies 2011-04-19 11:37:05 +02:00
commit 063194f8be
349 changed files with 36508 additions and 0 deletions

View file

@ -0,0 +1,50 @@
class Node {
int elem;
Node next;
void setElem(int c) { elem = c; }
void setNext(Node n) { next = n; }
int getElem() { return elem; }
Node getNext() { return next; }
}
class Stack {
Node head;
void push(int c) {
Node newHead = new Node;
newHead.setElem(c);
newHead.setNext(head);
head = newHead;
}
boolean isEmpty() {
return head==(Node)null;
}
int top() {
return head.getElem();
}
void pop() {
head = head.getNext();
}
}
int main() {
Stack s = new Stack;
int i= 0;
while (i<10) {
s.push(i);
i++;
}
while (!s.isEmpty()) {
printInt(s.top());
s.pop();
}
return 0;
}