1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
| #include "list.h"
int main() { int i = 0; int num = 0; List *list = NULL; List *list1 = NULL; List *list2 = NULL; List_node * node = NULL; printf("1.init_list:\n"); list = init_list(); list1 = init_list(); list2 = init_list(); printf("3.1 list1 push_front :\n"); for(i = 0; i < 6; i++) { push_front(list1, rand()%100); }
show_list(list1);
printf("3.2 list2 push_back:\n"); for(i = 0; i < 4; i++) { push_back(list2, rand()%100); } show_list(list2);
printf("4.1 list1 pop_front:\n"); pop_front(list1); show_list(list1);
printf("4.2 list2 pop_back:\n"); pop_back(list2); show_list(list2); printf("7.1 sort_list1_ascend:\n"); sort_list_ascend(list1); show_list(list1); printf("7.2 sort_list2_descend:\n"); sort_list_descend(list2); show_list(list2);
printf("12 reverse_list2:\n"); reverse_list(list2); show_list(list2); #if 0 printf("10. list : merge_two_lists(list1, list2):\n"); list = merge_two_lists(list1, list2); show_list(list); #endif
#if 1 printf("11. list : merge_two_lists_recure(list1, list2):\n"); list = merge_two_lists_recure(list1, list2); show_list(list); #endif printf("8.1 show_list(list);\n"); show_list(list);
printf("8.2 reverse_show_list(list);\n"); reverse_show_list(list); #if 1 printf("find_node:\n"); printf("which one?(value to find)\n"); scanf("%d",&num); printf("found num of list is :%d \n",find_node(list, num)->data); #endif
#if 1 printf("find_revise_node:\n"); printf("which one index ?(reverse)\n"); scanf("%d",&num); printf("reverse num of list is :%d \n",find_revise_node(list, num)->data); #endif printf("5.3 find_mid_node(list):\n") ; printf("%d \n",find_mid_node(list)->data);
printf("9. get_list_count:\n"); printf("the count of list is :%d\n", get_list_count(list));
#if 1 printf("6.3 delete_one_node:"); printf("which one?(to delete)\n"); scanf("%d",&num); node = create_node(); node = find_node(list,num); delete_one_node(list, node); show_list(list); #endif
#if 1 printf("6.1 modify_node :\n"); modify_node(list, 1, 26); show_list(list); #endif
#if 1 printf("6.2 insert_node: \n"); insert_node(list, 2, 18); show_list(list); #endif
#if 1 printf("16. has_circle:\n"); //list->head->next->next->next->next->next = list->head->next;
if(has_circle(list)) { printf("17 find_circle_first_node:\n"); find_circle_first_node(list); } #endif printf("13. list1:list_dump(list)\n"); list1 = list_dump(list); printf("list1: "); show_list(list1); printf("14. is_list_intersect:\n"); if(is_list_intersect(list1, list)) { printf("the common node: %d\n",get_first_common_node(list1, list)); }
printf("2. destroy_list:\n"); destroy_list(&list1); destroy_list(&list2); destroy_list(&list); return 0; }
|