mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-13 23:56:07 +00:00
Reformat the C# codes.
Disable creating new line before open brace.
This commit is contained in:
@@ -10,19 +10,15 @@ using System.IO;
|
||||
|
||||
namespace hello_algo.chapter_backtracking;
|
||||
|
||||
public class preorder_traversal_i_compact
|
||||
{
|
||||
public class preorder_traversal_i_compact {
|
||||
static List<TreeNode> res;
|
||||
|
||||
/* 前序遍历:例题一 */
|
||||
static void preOrder(TreeNode root)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
static void preOrder(TreeNode root) {
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
if (root.val == 7)
|
||||
{
|
||||
if (root.val == 7) {
|
||||
// 记录解
|
||||
res.Add(root);
|
||||
}
|
||||
@@ -31,8 +27,7 @@ public class preorder_traversal_i_compact
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test()
|
||||
{
|
||||
public void Test() {
|
||||
TreeNode root = TreeNode.ListToTree(new List<int?> { 1, 7, 3, 4, 5, 6, 7 });
|
||||
Console.WriteLine("\n初始化二叉树");
|
||||
PrintUtil.PrintTree(root);
|
||||
@@ -44,4 +39,4 @@ public class preorder_traversal_i_compact
|
||||
Console.WriteLine("\n输出所有值为 7 的节点");
|
||||
PrintUtil.PrintList(res.Select(p => p.val).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user