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)
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()

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