This commit is contained in:
Zengtudor 2024-12-07 21:43:44 +08:00
parent 9b2c5c58ed
commit 0401e39821
3 changed files with 57 additions and 21 deletions

View File

@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 3.10)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_options(-Wall) add_compile_options(-Wall)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-fexperimental-new-constant-interpreter)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
endif() endif()

42
src/11/c5/c5_tree.cpp Normal file
View File

@ -0,0 +1,42 @@
#include <iostream>
#include <fstream>
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;
}

View File

@ -1,22 +1,16 @@
#include <array>
#include <cstdint>
#include <iostream> #include <iostream>
#include <memory> #include <utility>
int main(){ #include <vector>
using namespace std; using namespace std;
struct X{ using ll = int64_t;
X(int const& x){cout<<"X is constructing: "<<x<<'\n';}
~X(){cout<<"X is dead\n";}
};
struct T{
T():t{1}{};
int t;
};
auto b = make_unique<X>(1); ll const maxn=1e5+5;
int t{5}; // vector<vector<pair<ll, ll>>> v(maxn);
while(t--){ vector<vector<pair<ll, ll>>> arr(maxn);
T t;
cout<<t.t<<'\n'; int main(){
}
cout<<"retrun 0;\n"; cout<<"hello world!\n";
return 0;
} }