Example #1
0
int main(int argc,char* argv[])
{
	node* head = createLinkList(10);
	printList(head);
	deleteNode(head,head->next->next);
	printList(head);
	findKthToTail(head,5);
	head = reverseList(head);
	printList(head);
	return 0;
}
int main(int argc, const char *argv[])
{
    LinkList L;
    int k;
    autoCreateLinkList(&L, 10);
    printLinkList(L);

    printf("Input K: ");
    scanf("%d",&k);
    findKthToTail(L, k);

    return 0;
}
Example #3
0
int main(int argc, char* argv[])
{
    int array[] = {1, 2, 3, 4, 5, 6};
    Node* head = initList(array, 6);

    assert(findKthToTail(head, 3)->value == 4);
    assert(findKthToTail(head, 7) == NULL);
    assert(findKthToTail(NULL, 3) == NULL);
    assert(findKthToTail(head, 0) == NULL);
    assert(findKthToTail(head, 1)->value == 6);
    assert(findKthToTail(head, 6)->value == 1);

    printf("all test case passed!\n");
    return 0;
}