From 0401e39821b13803baacb20070790e3f8ee7f8d7 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sat, 7 Dec 2024 21:43:44 +0800 Subject: [PATCH] update --- CMakeLists.txt | 4 +-- src/11/c5/c5_tree.cpp | 42 ++++++++++++++++++++++++++++++++ src/11/helloworld/helloworld.cpp | 32 ++++++++++-------------- 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 src/11/c5/c5_tree.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ca077f3..3a088eb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_compile_options(-Wall) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) - +add_compile_options(-fexperimental-new-constant-interpreter) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() diff --git a/src/11/c5/c5_tree.cpp b/src/11/c5/c5_tree.cpp new file mode 100644 index 0000000..848286f --- /dev/null +++ b/src/11/c5/c5_tree.cpp @@ -0,0 +1,42 @@ +#include +#include + +using namespace std; + +int tree[114514][2]; +int root; +int nodeCount; + +void input() { + ifstream inFile("dfs.in"); + inFile >> nodeCount; + for (int i = 0; i < 109; i++) { + tree[i][0] = -1; + tree[i][1] = -1; + } + for (int i = 1; i <= nodeCount; i++) { + int parent, leftChild, rightChild; + inFile >> parent >> leftChild >> rightChild; + tree[parent][0] = leftChild; + tree[parent][1] = rightChild; + } + inFile.close(); +} + +void dfs(int curNode) { + cout << curNode << " "; + if (tree[curNode][0] != -1) { + dfs(tree[curNode][0]); + } + if (tree[curNode][1] != -1) { + dfs(tree[curNode][1]); + } +} + + +int main() { + input(); + root = 1; + dfs(root); + return 0; +} diff --git a/src/11/helloworld/helloworld.cpp b/src/11/helloworld/helloworld.cpp index aaf18b3..f04de7a 100755 --- a/src/11/helloworld/helloworld.cpp +++ b/src/11/helloworld/helloworld.cpp @@ -1,22 +1,16 @@ +#include +#include #include -#include -int main(){ - using namespace std; - struct X{ - X(int const& x){cout<<"X is constructing: "< +#include +using namespace std; +using ll = int64_t; - auto b = make_unique(1); - int t{5}; - while(t--){ - T t; - cout<>> v(maxn); +vector>> arr(maxn); + +int main(){ + + cout<<"hello world!\n"; } \ No newline at end of file