//to do: seek
//to do: store
#define count(NODE,HEAD,VAR) { _NEW(I,0) for(NODE=HEAD; NODE || ((VAR=_I),0) ; (NODE=NODE->__next)?(_I++):0 ); }
-#define order_by_int(K1,K2) (K1>K2)
-#define order_by_int_desc(K1,K2) (K1<K2)
+#define order_by_num(K1,K2) (K1>K2)
+#define order_by_num_desc(K1,K2) (K1<K2)
#define order_by_str(K1,K2) (str_order(K1,K2)>0)
#define order_by_str_desc(K1,K2) (str_order(K1,K2)<0)
#define order_by_ascii(K1,K2) (str_ascii(K1,K2)>0)
--- /dev/null
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+\r
+struct Node \r
+{\r
+ float f;\r
+ struct Node* next;\r
+};\r
+\r
+void IterateList (struct Node* HeadList);\r
+struct Node* makelist(struct Node** Head, struct Node** Tail);\r
+\r
+struct Node* makelist(struct Node** Head, struct Node** Tail)\r
+{\r
+ struct Node* new = (struct Node *)malloc(sizeof (struct Node));\r
+ new->next = NULL;\r
+\r
+ if (*Head == NULL)\r
+ {\r
+ *Head = new;\r
+ *Tail = *Head;\r
+ }\r
+ else\r
+ {\r
+ (*Tail)->next = new;\r
+ *Tail = new;\r
+ }\r
+ return (new);\r
+}\r
+void IterateList (struct Node* HeadList)\r
+{\r
+ struct Node* current = HeadList;\r
+\r
+ while (current != NULL)\r
+ {\r
+ printf("The float you entered is %f\n",current->f);\r
+ current = current->next;\r
+ }\r
+}\r
+int main(void)\r
+{\r
+ struct Node* head = NULL;\r
+ struct Node* tail = NULL;\r
+ struct Node* curr = NULL;\r
+ int i;\r
+\r
+ for(i=0; i < 20; i++)\r
+ {\r
+ /* create node */\r
+ curr = makelist(&head,&tail);\r
+ printf("Enter float :\n");\r
+ scanf("%f", &(curr->f));\r
+ }\r
+\r
+ /* now iterate the list */\r
+ IterateList(head);\r
+\r
+ return 0;\r
+}\r
+++ /dev/null
-#include "cll1.h"
-
-def_mem(Record)
-{
- int i;
- str s;
- list(Record);
-};
-
-program
-{
- Record record, records=NULL;
-
- print("4x insert(record,records,order_by_int,i);");
-
- record=get_mem(Record);
- record->i=1;
- record->s="ddd";
- insert(record,records,order_by_int,i);
-
- record=get_mem(Record);
- record->i=3;
- record->s="BBBB";
- insert(record,records,order_by_int,i);
-
- record=get_mem(Record);
- record->i=4;
- record->s="e";
- insert(record,records,order_by_int,i);
-
- record=get_mem(Record);
- record->i=2;
- record->s="aaaa";
- insert(record,records,order_by_int,i);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-
- print("1x append(record,records);");
- record=get_mem(Record);
- record->i=0;
- record->s="ccc";
- append(record,records);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-
- print("sort(record,records,order_by_int_desc,i);");
- sort(record,records,order_by_int_desc,i);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-
- print("sort(record,records,order_by_str,s);");
- sort(record,records,order_by_str,s);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-
- print("sort(record,records,order_by_ascii_desc,s);");
- sort(record,records,order_by_ascii_desc,s);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-
- print("remove(record,records,record->i==1);");
- remove(record,records,record->i==1);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-
- print("drop(record,records);");
- drop(record,records);
-
- for_each(record,records)
- {
- printf("i=%d, s=%s\n",record->i,record->s);
- }
-}
--- /dev/null
+../cll1.h
\ No newline at end of file
--- /dev/null
+#include "cll1.h"
+
+def_mem(Node)
+{
+ float f;
+ list(Node);
+};
+
+program
+{
+ Node one,all=NULL;
+
+ repeat(20)
+ {
+ one=get_mem(Node);
+ printf("Enter float: \n");
+ scanf("%f", &(one->f));
+ insert(one,all,order_by_num,f);
+ }
+
+ for_each(one,all)
+ {
+ printf("The float you entered is %f\n",one->f);
+ }
+}
--- /dev/null
+#include "cll1.h"
+
+def_mem(Node)
+{
+ float f;
+ list(Node);
+};
+
+program
+{
+ Node one,all=NULL,last=NULL;
+
+ repeat(20)
+ {
+ one=get_mem(Node);
+ printf("Enter float: \n");
+ scanf("%f", &(one->f));
+ append(one,last);
+ if(not all)
+ {
+ all=last;
+ }
+ }
+
+ for_each(one,all)
+ {
+ printf("The float you entered is %f\n",one->f);
+ }
+}
--- /dev/null
+#include "cll1.h"
+
+def_mem(Record)
+{
+ int i;
+ str s;
+ list(Record);
+};
+
+program
+{
+ Record record, records = NULL;
+
+ print("4x insert(record,records,order_by_num,i);");
+
+ record = get_mem(Record);
+ record->i = 1;
+ record->s = "ddd";
+ insert(record, records, order_by_num, i);
+
+ record = get_mem(Record);
+ record->i = 3;
+ record->s = "BBBB";
+ insert(record, records, order_by_num, i);
+
+ record = get_mem(Record);
+ record->i = 4;
+ record->s = "e";
+ insert(record, records, order_by_num, i);
+
+ record = get_mem(Record);
+ record->i = 2;
+ record->s = "aaaa";
+ insert(record, records, order_by_num, i);
+
+ for_each(record, records)
+ {
+ printf("i=%d, s=%s\n", record->i, record->s);
+ }
+
+ print("1x append(record,records);");
+
+ record = get_mem(Record);
+ record->i = 0;
+ record->s = "ccc";
+ append(record, records);
+
+ for_each(record, records)
+ {
+ printf("i=%d, s=%s\n", record->i, record->s);
+ }
+
+ print("sort(record,records,order_by_num_desc,i);");
+
+ sort(record, records, order_by_num_desc, i);
+
+ for_each(record, records)
+ {
+ printf("i=%d, s=%s\n", record->i, record->s);
+ }
+
+ print("sort(record,records,order_by_str,s);");
+
+ sort(record, records, order_by_str, s);
+
+ for_each(record, records)
+ {
+ printf("i=%d, s=%s\n",record->i,record->s);
+ }
+
+ print("sort(record, records, order_by_ascii_desc, s);");
+
+ sort(record, records, order_by_ascii_desc, s);
+
+ for_each(record,records)
+ {
+ printf("i=%d, s=%s\n", record->i, record->s);
+ }
+
+ print("remove(record,records,record->i==1);");
+ remove(record, records, record->i == 1);
+
+ for_each(record,records)
+ {
+ printf("i=%d, s=%s\n", record->i, record->s);
+ }
+
+ print("drop(record,records);");
+ drop(record, records);
+
+ for_each(record, records)
+ {
+ printf("i=%d, s=%s\n", record->i, record->s);
+ }
+}