mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-27 12:22:45 +08:00
feat(codes/c): add C include/ codes and modify exist C codes
This commit is contained in:
38
codes/c/include/include_test.c
Normal file
38
codes/c/include/include_test.c
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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);
|
||||
ListNode *head = ArrayToLinkedList(nums, size);
|
||||
PrintLinkedList(head);
|
||||
|
||||
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);
|
||||
TreeNode *root = ArrayToTree(nums, size);
|
||||
|
||||
// print tree
|
||||
PrintTree(root);
|
||||
|
||||
// tree to arr
|
||||
int *arr = TreeToArray(root);
|
||||
PrintArray(arr, size);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
printf("==testListNode==\n");
|
||||
testListNode();
|
||||
printf("==testTreeNode==\n");
|
||||
testTreeNode();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user