Format the C code in Clang-Format Style: Microsoft

This commit is contained in:
krahets
2023-04-17 21:13:15 +08:00
parent 1d6b7a5644
commit 9a98ff8a5e
46 changed files with 215 additions and 216 deletions

View File

@@ -7,16 +7,16 @@
#ifndef C_INCLUDE_H
#define C_INCLUDE_H
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#include <assert.h>
#include "list_node.h"
#include "tree_node.h"
#include "print_util.h"
#include "tree_node.h"
// hash table lib
#include "uthash.h"

View File

@@ -22,7 +22,7 @@ typedef struct ListNode ListNode;
/* 构造函数,初始化一个新节点 */
ListNode *newListNode(int val) {
ListNode *node, *next;
node = (ListNode *) malloc(sizeof(ListNode));
node = (ListNode *)malloc(sizeof(ListNode));
node->val = val;
node->next = NULL;
return node;

View File

@@ -8,8 +8,8 @@
#define PRINT_UTIL_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include "list_node.h"
#include "tree_node.h"
@@ -18,7 +18,6 @@
extern "C" {
#endif
/**
* @brief Print an Array
*
@@ -69,9 +68,9 @@ struct Trunk {
typedef struct Trunk Trunk;
Trunk *newTrunk(Trunk *prev, char *str) {
Trunk *trunk = (Trunk *) malloc(sizeof(Trunk));
Trunk *trunk = (Trunk *)malloc(sizeof(Trunk));
trunk->prev = prev;
trunk->str = (char *) malloc(sizeof(char) * 10);
trunk->str = (char *)malloc(sizeof(char) * 10);
strcpy(trunk->str, str);
return trunk;
}
@@ -146,7 +145,6 @@ static void printHeap(int arr[], int size) {
printTree(root);
}
#ifdef __cplusplus
}
#endif

View File

@@ -4,7 +4,6 @@
* Author: Reanon (793584285@qq.com)
*/
#ifndef TREE_NODE_H
#define TREE_NODE_H
@@ -24,11 +23,10 @@ struct TreeNode {
typedef struct TreeNode TreeNode;
TreeNode *newTreeNode(int val) {
TreeNode *node;
node = (TreeNode *) malloc(sizeof(TreeNode));
node = (TreeNode *)malloc(sizeof(TreeNode));
node->val = val;
node->height = 0;
node->left = NULL;
@@ -55,7 +53,7 @@ TreeNode *arrToTree(const int *arr, size_t size) {
/* 根节点 */
root = newTreeNode(arr[0]);
/* 辅助队列 */
queue = (TreeNode **) malloc(sizeof(TreeNode) * MAX_NODE_SIZE);
queue = (TreeNode **)malloc(sizeof(TreeNode) * MAX_NODE_SIZE);
// 队列指针
front = 0, rear = 0;
// 将根节点放入队尾
@@ -83,7 +81,6 @@ TreeNode *arrToTree(const int *arr, size_t size) {
return root;
}
/**
* @brief Generate a binary tree with an array
*
@@ -100,13 +97,13 @@ int *treeToArr(TreeNode *root) {
TreeNode *node;
TreeNode **queue;
/* 辅助队列 */
queue = (TreeNode **) malloc(sizeof(TreeNode) * MAX_NODE_SIZE);
queue = (TreeNode **)malloc(sizeof(TreeNode) * MAX_NODE_SIZE);
// 队列指针
front = 0, rear = 0;
// 将根节点放入队尾
queue[rear++] = root;
/* 辅助数组 */
arr = (int *) malloc(sizeof(int) * MAX_NODE_SIZE);
arr = (int *)malloc(sizeof(int) * MAX_NODE_SIZE);
// 数组指针
index = 0;
while (front < rear) {