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.
pull/420/head
Gonglja 2 years ago committed by GitHub
parent d09b1e4f9f
commit 567497a6b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

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

@ -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));
}

@ -0,0 +1,2 @@
add_executable(array_hash_map array_hash_map.cpp)
add_executable(hash_map hash_map.cpp)

@ -0,0 +1,2 @@
add_executable(heap heap.cpp)
add_executable(my_heap my_heap.cpp)

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

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

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

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

@ -0,0 +1,4 @@
add_executable(include
include.hpp PrintUtil.hpp
ListNode.hpp TreeNode.hpp
Vertex.hpp)
Loading…
Cancel
Save