mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
Add cpp codes cmake build method (#419)
* feat(codes/cpp): Add cmake build method * feat(codes/cpp): Modify the cpp support version to c++17 * feat(codes/cpp): fix graph_adjacency_list.cpp cannot be compiled into an executable * style(codes/cpp): Adjust the code to enhance compatibility. * feat(codes/cpp): Change cpp version from 17 to 11.
This commit is contained in:
5
codes/cpp/chapter_graph/CMakeLists.txt
Normal file
5
codes/cpp/chapter_graph/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_executable(graph_bfs graph_bfs.cpp)
|
||||
add_executable(graph_dfs graph_dfs.cpp)
|
||||
# add_executable(graph_adjacency_list graph_adjacency_list.cpp)
|
||||
add_executable(graph_adjacency_list_test graph_adjacency_list_test.cpp)
|
||||
add_executable(graph_adjacency_matrix graph_adjacency_matrix.cpp)
|
||||
@ -75,7 +75,9 @@ public:
|
||||
/* 打印邻接表 */
|
||||
void print() {
|
||||
cout << "邻接表 =" << endl;
|
||||
for (auto& [key, vec] : adjList) {
|
||||
for (auto& adj : adjList) {
|
||||
const auto& key= adj.first;
|
||||
const auto& vec = adj.second;
|
||||
cout << key->val << ": ";
|
||||
PrintUtil::printVector(vetsToVals(vec));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user