hello-algo/codes/c/include/include_test.c

39 lines
819 B
C
Raw Normal View History

/**
* File: include_test.c
* Created Time: 2023-01-10
* Author: Reanon (793584285@qq.com)
*/
#include "include.h"
void testListNode() {
int nums[] = {2, 3, 5, 6, 7};
int size = sizeof(nums) / sizeof(int);
2023-01-12 00:31:11 +08:00
ListNode *head = arrToLinkedList(nums, size);
printLinkedList(head);
2023-01-12 00:31:11 +08:00
ListNode *node = getListNode(head, 5);
printf("find node: %d\n", node->val);
}
void testTreeNode() {
int nums[] = {1, 2, 3, NIL, 5, 6, NIL};
int size = sizeof(nums) / sizeof(int);
2023-01-12 00:31:11 +08:00
TreeNode *root = arrToTree(nums, size);
// print tree
2023-01-12 00:31:11 +08:00
printTree(root);
// tree to arr
2023-01-12 00:31:11 +08:00
int *arr = treeToArr(root);
printArray(arr, size);
}
int main(int argc, char *argv[]) {
printf("==testListNode==\n");
testListNode();
printf("==testTreeNode==\n");
testTreeNode();
return 0;
}