void test_insert_at_beginning(void){ linked_list * head = NULL; head = insert_at_beginning(head, 10); display(head); head = insert_at_beginning(head, 20); display(head); head = insert_at_beginning(head, 30); display(head); }
linked_list * reverse2(linked_list * node){ linked_list * new_head = NULL; while(node){ int value = node->data; node = remove_node(node, value); linked_list * new_node = create_node(value); new_head = insert_at_beginning(new_head, value); } return new_head; }
int main() { struct node* head; int data; printf("\nenter element\n"); scanf("%d", &data); while (data != -1) { head = insert_at_beginning(head, data); scanf("%d", &data); } traverse_ll(head); head = rearrange_ll(head); printf("\n"); traverse_ll(head); return 0; }