Skip to content

Commit bca0adc

Browse files
committed
update readme
1 parent a9cf3dd commit bca0adc

File tree

13 files changed

+41
-35
lines changed

13 files changed

+41
-35
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# Algorithms
22
Algorithms, 4th edition textbook code (using c++)
33

4+
> official java code: [Algorithms, 4th Edition](https://algs4.cs.princeton.edu/home/)
5+
46
**Note:**
57

68
1. based on STL Library
7-
2. using C++14
9+
2. using C++17
810
3. **Not support** drawing
9-
4. **Bug: ** ① const object (many member function forget to add const)
1011
4. Welcome to point out the error, and pull better code
1112

13+
### TODO
14+
15+
- [ ] check ch1
16+
- [ ] check ch2
17+
- [ ] check ch3
18+
- [ ] check ch4
19+
- [ ] check ch5
20+
- [ ] add ch6
21+
1222
## Tutorial: run demo code
1323

1424
### terminal

ch1/1_BinarySearch/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(1_BinarySearch)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(1_BinarySearch ${SOURCE_FILES})

ch1/2_RandomSeq/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(2_RandomSeq)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(2_RandomSeq ${SOURCE_FILES})

ch1/2_RandomSeq/main.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@ mt19937 g(rd());
1414
* @param args the command-line arguments
1515
*/
1616
int main() {
17-
int n = 10;
18-
double lo = 0.0, hi = 1.0;
19-
// uniform[0.0, 1.0)
20-
uniform_real_distribution<double> dis(0.0, 1.0);
21-
cout << fixed;
22-
for (int i = 0; i < n; ++i)
23-
cout << setprecision(4) << dis(g) << " ";
24-
cout << endl;
17+
int n;
18+
double lo, hi;
19+
cout << "Prints numbers: ";
20+
cin >> n;
21+
cout << "Range number (lo, high): ";
22+
cin >> lo >> hi;
2523
// uniform[lo, high)
26-
lo = 2.5, hi = 3.0;
27-
uniform_real_distribution<double> dis2(lo, hi);
24+
uniform_real_distribution<double> dis(lo, hi);
2825
for (int i = 0; i < n; ++i)
29-
cout << setprecision(4) << dis2(g) << " ";
26+
cout << setprecision(4) << dis(g) << " ";
3027
cout << endl;
3128
}

ch1/3_Average/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(3_Average)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(3_Average ${SOURCE_FILES})

ch1/4_Cat/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(4_Cat)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(4_Cat ${SOURCE_FILES})

ch1/5_Knuth/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(5_Knuth)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(5_Knuth ${SOURCE_FILES})

ch1/6_Counter/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(6_Counter)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(6_Counter ${SOURCE_FILES})

ch1/7_StaticSETofInts/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(7_StaticSETofInts)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(7_StaticSETofInts ${SOURCE_FILES})

ch1/7_StaticSETofInts/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ using namespace std;
88
*
99
*/
1010
int main() {
11-
StaticSETofInts *s = new StaticSETofInts({4, 2, 3, 6, 5});
11+
const StaticSETofInts *s = new StaticSETofInts({4, 2, 3, 6, 5});
1212
cout << s->contains(5) << endl;
1313
}

ch1/8_Whitelist/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(8_Whitelist)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(8_Whitelist ${SOURCE_FILES})

ch1/9_vector/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(9_vector)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(SOURCE_FILES main.cpp)
77
add_executable(9_vector ${SOURCE_FILES})

ch1/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.12)
22
project(ch1)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

6-
#add_subdirectory(head)
76
include_directories(head)
87
include_directories(data)
98

0 commit comments

Comments
 (0)