Format C++ codes in Clang-Format Style: Microsoft

This commit is contained in:
krahets
2023-04-14 03:44:02 +08:00
parent f8513455b5
commit 9c9c8b7574
46 changed files with 732 additions and 888 deletions

View File

@ -48,7 +48,8 @@ void linear(int n) {
/* 线性阶(递归实现) */
void linearRecur(int n) {
cout << "递归 n = " << n << endl;
if (n == 1) return;
if (n == 1)
return;
linearRecur(n - 1);
}
@ -67,22 +68,23 @@ void quadratic(int n) {
/* 平方阶(递归实现) */
int quadraticRecur(int n) {
if (n <= 0) return 0;
if (n <= 0)
return 0;
vector<int> nums(n);
cout << "递归 n = " << n << " 中的 nums 长度 = " << nums.size() << endl;
return quadraticRecur(n - 1);
}
/* 指数阶(建立满二叉树) */
TreeNode* buildTree(int n) {
if (n == 0) return nullptr;
TreeNode* root = new TreeNode(0);
TreeNode *buildTree(int n) {
if (n == 0)
return nullptr;
TreeNode *root = new TreeNode(0);
root->left = buildTree(n - 1);
root->right = buildTree(n - 1);
return root;
}
/* Driver Code */
int main() {
int n = 5;
@ -95,8 +97,8 @@ int main() {
quadratic(n);
quadraticRecur(n);
// 指数阶
TreeNode* root = buildTree(n);
PrintUtil::printTree(root);
TreeNode *root = buildTree(n);
printTree(root);
// 释放内存
freeMemoryTree(root);