Fine tune the C codes.

This commit is contained in:
krahets
2023-04-17 22:15:06 +08:00
parent c4ea4e39f3
commit af0f92c18d
15 changed files with 29 additions and 103 deletions

View File

@@ -18,12 +18,7 @@
extern "C" {
#endif
/**
* @brief Print an Array
*
* @param arr
* @param size
*/
/* Print an Array */
static void printArray(int arr[], int size) {
printf("[");
if (arr != NULL && size != 0) {
@@ -44,11 +39,7 @@ static void printArray(int arr[], int size) {
}
}
/**
* @brief Print a linked list
*
* @param head
*/
/* Print a linked list */
static void printLinkedList(ListNode *node) {
if (node == NULL) {
return;
@@ -75,11 +66,7 @@ Trunk *newTrunk(Trunk *prev, char *str) {
return trunk;
}
/**
* @brief Helper function to print branches of the binary tree
*
* @param trunk
*/
/* Helper function to print branches of the binary tree */
void showTrunks(Trunk *trunk) {
if (trunk == NULL) {
return;
@@ -88,12 +75,7 @@ void showTrunks(Trunk *trunk) {
printf("%s", trunk->str);
}
/**
* Help to print a binary tree, hide more details
* @param node
* @param prev
* @param isLeft
*/
/* Help to print a binary tree, hide more details */
static void printTreeHelper(TreeNode *node, Trunk *prev, bool isLeft) {
if (node == NULL) {
return;
@@ -121,21 +103,12 @@ static void printTreeHelper(TreeNode *node, Trunk *prev, bool isLeft) {
printTreeHelper(node->left, trunk, false);
}
/**
* @brief Print a binary tree
*
* @param head
*/
/* Print a binary tree */
static void printTree(TreeNode *root) {
printTreeHelper(root, NULL, false);
}
/**
* @brief Print a Heap
*
* @param arr
* @param size
*/
/* Print a Heap */
static void printHeap(int arr[], int size) {
TreeNode *root;
printf("堆的数组表示:");