X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fpalllist.c;h=daab2b3840d15d93baacd18c1b533269344284de;hb=48a59b737b260f4ae17210137c19486d1cc42eb3;hp=f6949c1a69db70c84fc916c0102db2b547b64521;hpb=3274c29216a03baeac8668301301b41257fc2fd2;p=16.git diff --git a/src/palllist.c b/src/palllist.c index f6949c1a..daab2b38 100755 --- a/src/palllist.c +++ b/src/palllist.c @@ -59,39 +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; - node_t * nx = NULL; - head = malloc(sizeof(node_t)); heao = malloc(sizeof(node_t)); - head->val = 0; heao->val = 9; - head->next=NULL; heao->next=NULL; + 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; - nx = head; - for(i=1; i< + printf(" "); + for(i=1; i<= //PAL_SIZE - 5 + 6 ; i++) { - printf(" i=%d\n", i); - pushe(nx, i); - nx = nx->next; + if(!(i%3)) printf("\n "); + printf("%d,", i); + pushe(vga, i); + } + + printf("\n\n "); + + for(i=4; i>0; i--) + { + if(!(i%3)) printf("\n "); + printf("%d,", i); + pushe(imgpal, i); } - nx->next = NULL; + printf("\n"); - nx = heao; - for(i=8; i>0; i--) + 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)) { - printf(" i=%d\n", i); - pushe(nx, i); - nx = nx->next; + } - nx->next = NULL; - 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