X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=blobdiff_plain;f=samples%2Flinkedlist.mj;fp=samples%2Flinkedlist.mj;h=0000000000000000000000000000000000000000;hp=6d047461a901b84f9ba45fd3e7ded1ec219961dd;hb=77e39fac55f1a366814d35e75659cb6d88cca4e1;hpb=306587b78e421a7221952e44adde831723748e4c diff --git a/samples/linkedlist.mj b/samples/linkedlist.mj deleted file mode 100644 index 6d04746..0000000 --- a/samples/linkedlist.mj +++ /dev/null @@ -1,85 +0,0 @@ -program linkedlist - class Element { - int info; - Element next; - } - Element first; -{ - void add(int i) - Element newone; - { - newone = new Element; - newone.info = i; - newone.next = first; - first = newone; - } - - void printlist() - Element cur; - { - cur = first; - while (cur != null) { - print(cur.info); - cur = cur.next; - } - } - - int exists(int i) Element cur; { - cur = first; - while (cur != null && cur.info != i) - cur = cur.next; - if (cur != null) - return 1; - else - return 0; - } - - int count(int i) Element cur; int c;{ - cur = first; - c = 0; - while (cur != null) { - if (cur.info == i) - c++; - cur = cur.next; - } - return c; - } - - void main() - int num; int in; int c; { - print('l'); - print('?'); - read(num); - // demo - if (num<0) { - add(1); - add(2); - add(3); - add(2); - printlist(); - print(exists(7)); - print(count(2)); - } else { - c = 0; - while (c