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