diff --git a/codes/cpp/CMakeLists.txt b/codes/cpp/CMakeLists.txt new file mode 100644 index 000000000..20705d64a --- /dev/null +++ b/codes/cpp/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +project(hello_algo CXX) + +set(CMAKE_CXX_STANDARD 11) + +include_directories(./include) + +add_subdirectory(chapter_tree) +add_subdirectory(chapter_stack_and_queue) +add_subdirectory(chapter_sorting) +add_subdirectory(chapter_searching) +add_subdirectory(chapter_heap) +add_subdirectory(chapter_graph) +add_subdirectory(chapter_hashing) +add_subdirectory(chapter_computational_complexity) +add_subdirectory(chapter_array_and_linkedlist) \ No newline at end of file diff --git a/codes/cpp/chapter_array_and_linkedlist/CMakeLists.txt b/codes/cpp/chapter_array_and_linkedlist/CMakeLists.txt new file mode 100644 index 000000000..0c69dc41d --- /dev/null +++ b/codes/cpp/chapter_array_and_linkedlist/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(array array.cpp) +add_executable(linked_list linked_list.cpp) +add_executable(list my_list.cpp) +add_executable(my_list my_list.cpp) \ No newline at end of file diff --git a/codes/cpp/chapter_computational_complexity/CMakeLists.txt b/codes/cpp/chapter_computational_complexity/CMakeLists.txt new file mode 100644 index 000000000..b484b3af2 --- /dev/null +++ b/codes/cpp/chapter_computational_complexity/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(leetcode_two_sum leetcode_two_sum.cpp) +add_executable(space_complexity space_complexity.cpp ) +add_executable(time_complexity time_complexity.cpp) +add_executable(worst_best_time_complexity worst_best_time_complexity.cpp) \ No newline at end of file diff --git a/codes/cpp/chapter_graph/CMakeLists.txt b/codes/cpp/chapter_graph/CMakeLists.txt new file mode 100644 index 000000000..4a56ce35b --- /dev/null +++ b/codes/cpp/chapter_graph/CMakeLists.txt @@ -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) diff --git a/codes/cpp/chapter_graph/graph_adjacency_list.cpp b/codes/cpp/chapter_graph/graph_adjacency_list.cpp index 3bef35d17..cef9746d3 100644 --- a/codes/cpp/chapter_graph/graph_adjacency_list.cpp +++ b/codes/cpp/chapter_graph/graph_adjacency_list.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)); } diff --git a/codes/cpp/chapter_hashing/CMakeLists.txt b/codes/cpp/chapter_hashing/CMakeLists.txt new file mode 100644 index 000000000..f5be6e507 --- /dev/null +++ b/codes/cpp/chapter_hashing/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(array_hash_map array_hash_map.cpp) +add_executable(hash_map hash_map.cpp) diff --git a/codes/cpp/chapter_heap/CMakeLists.txt b/codes/cpp/chapter_heap/CMakeLists.txt new file mode 100644 index 000000000..481b69730 --- /dev/null +++ b/codes/cpp/chapter_heap/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(heap heap.cpp) +add_executable(my_heap my_heap.cpp) diff --git a/codes/cpp/chapter_searching/CMakeLists.txt b/codes/cpp/chapter_searching/CMakeLists.txt new file mode 100644 index 000000000..9d2a23995 --- /dev/null +++ b/codes/cpp/chapter_searching/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(binary_search binary_search.cpp) +add_executable(hashing_search hashing_search.cpp) +add_executable(linear_search linear_search.cpp) \ No newline at end of file diff --git a/codes/cpp/chapter_sorting/CMakeLists.txt b/codes/cpp/chapter_sorting/CMakeLists.txt new file mode 100644 index 000000000..d1f11a857 --- /dev/null +++ b/codes/cpp/chapter_sorting/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(bubble_sort bubble_sort.cpp) +add_executable(insertion_sort insertion_sort.cpp) +add_executable(merge_sort merge_sort.cpp) +add_executable(quick_sort quick_sort.cpp) \ No newline at end of file diff --git a/codes/cpp/chapter_stack_and_queue/CMakeLists.txt b/codes/cpp/chapter_stack_and_queue/CMakeLists.txt new file mode 100644 index 000000000..b55878a17 --- /dev/null +++ b/codes/cpp/chapter_stack_and_queue/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(array_deque array_deque.cpp) +add_executable(array_queue array_queue.cpp) +add_executable(array_stack array_stack.cpp) +add_executable(deque deque.cpp) +add_executable(linkedlist_deque linkedlist_deque.cpp) +add_executable(linkedlist_queue linkedlist_queue.cpp) +add_executable(linkedlist_stack linkedlist_stack.cpp) +add_executable(queue queue.cpp) +add_executable(stack stack.cpp) diff --git a/codes/cpp/chapter_tree/CMakeLists.txt b/codes/cpp/chapter_tree/CMakeLists.txt new file mode 100644 index 000000000..3a9736758 --- /dev/null +++ b/codes/cpp/chapter_tree/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(avl_tree avl_tree.cpp) +add_executable(binary_search_tree binary_search_tree.cpp) +add_executable(binary_tree binary_tree.cpp) +add_executable(binary_tree_bfs binary_tree_bfs.cpp) +add_executable(binary_tree_dfs binary_tree_dfs.cpp) diff --git a/codes/cpp/include/CMakeLists.txt b/codes/cpp/include/CMakeLists.txt new file mode 100644 index 000000000..c9bc76ab8 --- /dev/null +++ b/codes/cpp/include/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(include + include.hpp PrintUtil.hpp + ListNode.hpp TreeNode.hpp + Vertex.hpp) \ No newline at end of file