]> 4ch.mooo.com Git - 16.git/blobdiff - src/palllist.c
notime
[16.git] / src / palllist.c
index eb428c1d6b9ba81ea78a72755601e29ea6f0828c..daab2b3840d15d93baacd18c1b533269344284de 100755 (executable)
  */\r
 #include "src/lib/ll.h"\r
 \r
+#if 0\r
+//def OTHERMERGELISTSTIFF\r
+\r
 void\r
 main(int argc, char *argv[])\r
 {\r
        int i;\r
-       node_t * head = NULL;           node_t * heao = NULL;\r
-       head = malloc(sizeof(node_t));  heao = malloc(sizeof(node_t));\r
-       head->val = 0;                  heao->val = 9;\r
-       head->next=NULL;                heao->next=NULL;\r
-       head->id=0;                             heao->id=0;\r
+       node_t * vga = NULL;                    node_t * imgpal = NULL;\r
+       vga = malloc(sizeof(node_t));   imgpal = malloc(sizeof(node_t));\r
+       vga->val = 24;                  imgpal->val = 9;\r
+       vga->next=NULL;                 imgpal->next=NULL;\r
+       vga->id=0;                              imgpal->id=0;\r
 \r
-       for(i=1; i<\r
+       printf("        ");\r
+       for(i=1; i<=\r
                //PAL_SIZE\r
-               7\r
+               6\r
                ; i++)\r
        {\r
                if(!(i%3)) printf("\n   ");\r
                printf("%d,", i);\r
-               pushe(head, i);\r
+               pushe(vga, i);\r
        }\r
 \r
-       printf("\n");\r
+       printf("\n\n    ");\r
 \r
-       for(i=8; i>0; i--)\r
+       for(i=4; i>0; i--)\r
        {\r
                if(!(i%3)) printf("\n   ");\r
                printf("%d,", i);\r
-               pushe(heao, i);\r
+               pushe(imgpal, i);\r
+       }\r
+       printf("\n");\r
+\r
+       printf("size of vga = %d\n", listLength(vga));\r
+//#if 0\r
+       printf("\n=======================\n");\r
+       printf("vga list printings\n=======================\n");\r
+       print_list(vga);\r
+       printf("\n=======================\n");\r
+       printf("imgpal list printings\n=======================\n");\r
+       print_list(imgpal);\r
+//     printf("\n=======================\n");\r
+//#endif\r
+       i=1;//skip overscan\r
+       while(i!=listLength(imgpal))\r
+       {\r
+               \r
        }\r
-       print_list(head);\r
+       free(vga);\r
+       free(imgpal);\r
+}\r
+#else\r
+#if 0\r
+/* C/C++ program to merge two sorted linked lists */\r
+//     from http://www.geeksforgeeks.org/merge-two-sorted-linked-lists/\r
+\r
+/* Drier program to test above functions*/\r
+void main()\r
+{\r
+       /* Start with the empty list */\r
+       struct node* res = NULL;\r
+       struct node* a = NULL;\r
+       struct node* b = NULL;\r
+\r
+       /* Let us create two sorted linked lists to test\r
+         the functions\r
+          Created lists, a: 5->10->15,  b: 2->3->20 */\r
+       pushll(&a, 15);\r
+       pushll(&a, 10);\r
+       pushll(&a, 4);\r
+       pushll(&a, 3);\r
+       pushll(&a, 2);\r
+       pushll(&a, 1);\r
+       pushll(&a, 0);\r
+\r
+       pushll(&b, 20);\r
+       pushll(&b, 3);\r
+       pushll(&b, 2);\r
+       pushll(&b, 4);\r
+\r
        printf("\n");\r
-       print_list(heao);\r
-       free(head);\r
-       free(heao);\r
+       printf("The 2 Linked List are: \n");\r
+       printList(a);   printf("\n");\r
+       printList(b);   printf("\n");\r
+\r
+       /* Remove duplicates from linked list */\r
+       res = SortedMerge(a, b);\r
+//     res = LL_merge(a, b);\r
+       \r
+       printf("Merged Linked List is: \n");\r
+       printList(res);\r
+}\r
+#endif\r
+/* C Program to remove duplicates from a sorted linked list */\r
+\r
+/* Drier program to test above functions*/\r
+void main()\r
+{\r
+       /* Start with the empty list */\r
+       struct node* head = NULL;\r
+   \r
+       /* Let us create a sorted linked list to test the functions\r
+        Created linked list will be 11->11->11->13->13->20 */\r
+       push(&head, 20);\r
+       push(&head, 13);\r
+       push(&head, 13);  \r
+       push(&head, 11);\r
+       push(&head, 11);\r
+       push(&head, 11); \r
\r
+       printf("\n Linked list before duplicate removal  ");\r
+       printList(head); \r
\r
+       /* Remove duplicates from linked list */\r
+       removeDuplicates(head); \r
\r
+       printf("\n Linked list after duplicate removal ");               \r
+       printList(head);                        \r
+       \r
 }\r
+#endif\r