diff --git a/codes/cpp/chapter_computational_complexity/time_complexity.cpp b/codes/cpp/chapter_computational_complexity/time_complexity.cpp index 5488af22a4..5e783edb82 100644 --- a/codes/cpp/chapter_computational_complexity/time_complexity.cpp +++ b/codes/cpp/chapter_computational_complexity/time_complexity.cpp @@ -158,7 +158,7 @@ int main() { count = logRecur(n); cout << "对数阶(递归实现)的操作数量 = " << count << endl; - count = linearLogRecur((n); + count = linearLogRecur(n); cout << "线性对数阶(递归实现)的操作数量 = " << count << endl; count = factorialRecur(n); diff --git a/codes/csharp/chapter_computational_complexity/time_complexity.cs b/codes/csharp/chapter_computational_complexity/time_complexity.cs index 4c103b3da5..0f3efa4bcf 100644 --- a/codes/csharp/chapter_computational_complexity/time_complexity.cs +++ b/codes/csharp/chapter_computational_complexity/time_complexity.cs @@ -10,7 +10,7 @@ public class time_complexity { void Algorithm(int n) { int a = 1; // +0(技巧 1) a += n; // +0(技巧 1) - // +n(技巧 2) + // +n(技巧 2) for (int i = 0; i < 5 * n + 1; i++) { Console.WriteLine(0); } diff --git a/codes/dart/chapter_computational_complexity/time_complexity.dart b/codes/dart/chapter_computational_complexity/time_complexity.dart index 906406813e..3bc3afc4b7 100644 --- a/codes/dart/chapter_computational_complexity/time_complexity.dart +++ b/codes/dart/chapter_computational_complexity/time_complexity.dart @@ -90,7 +90,7 @@ int expRecur(int n) { int logarithmic(int n) { int count = 0; while (n > 1) { - n = n / 2; + n = n ~/ 2; count++; } return count; @@ -99,13 +99,13 @@ int logarithmic(int n) { /* 对数阶(递归实现) */ int logRecur(int n) { if (n <= 1) return 0; - return logRecur(n / 2) + 1; + return logRecur(n ~/ 2) + 1; } /* 线性对数阶 */ int linearLogRecur(int n) { if (n <= 1) return 1; - int count = linearLogRecur(n / 2) + linearLogRecur(n / 2); + int count = linearLogRecur(n ~/ 2) + linearLogRecur(n ~/ 2); for (var i = 0; i < n; i++) { count++; }