fix: Polishing code format on linearLogRecur, convert String type to string (#841)

This commit is contained in:
hpstory 2023-10-08 20:33:30 +08:00 committed by GitHub
parent 2bba70fd87
commit e03022d5fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 16 deletions

View file

@ -134,8 +134,7 @@ public class time_complexity {
/* 线性对数阶 */ /* 线性对数阶 */
static int LinearLogRecur(float n) { static int LinearLogRecur(float n) {
if (n <= 1) return 1; if (n <= 1) return 1;
int count = LinearLogRecur(n / 2) + int count = LinearLogRecur(n / 2) + LinearLogRecur(n / 2);
LinearLogRecur(n / 2);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
count++; count++;
} }

View file

@ -17,11 +17,8 @@ public class worst_best_time_complexity {
// 随机打乱数组元素 // 随机打乱数组元素
for (int i = 0; i < nums.Length; i++) { for (int i = 0; i < nums.Length; i++) {
var index = new Random().Next(i, nums.Length); int index = new Random().Next(i, nums.Length);
var tmp = nums[i]; (nums[i], nums[index]) = (nums[index], nums[i]);
var ran = nums[index];
nums[i] = ran;
nums[index] = tmp;
} }
return nums; return nums;
} }

View file

@ -109,8 +109,7 @@ func linearLogRecur(n float64) int {
if n <= 1 { if n <= 1 {
return 1 return 1
} }
count := linearLogRecur(n/2) + count := linearLogRecur(n / 2) + linearLogRecur(n / 2)
linearLogRecur(n/2)
for i := 0.0; i < n; i++ { for i := 0.0; i < n; i++ {
count++ count++
} }

View file

@ -107,8 +107,7 @@ public class time_complexity {
static int linearLogRecur(float n) { static int linearLogRecur(float n) {
if (n <= 1) if (n <= 1)
return 1; return 1;
int count = linearLogRecur(n / 2) + int count = linearLogRecur(n / 2) + linearLogRecur(n / 2);
linearLogRecur(n / 2);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
count++; count++;
} }

View file

@ -111,8 +111,7 @@ fn linear_log_recur(n: f32) -> i32 {
if n <= 1.0 { if n <= 1.0 {
return 1; return 1;
} }
let mut count = linear_log_recur(n / 2.0) + let mut count = linear_log_recur(n / 2.0) + linear_log_recur(n / 2.0);
linear_log_recur(n / 2.0);
for _ in 0 ..n as i32 { for _ in 0 ..n as i32 {
count += 1; count += 1;
} }

View file

@ -115,8 +115,7 @@ fn logRecur(n: f32) i32 {
// 线 // 线
fn linearLogRecur(n: f32) i32 { fn linearLogRecur(n: f32) i32 {
if (n <= 1) return 1; if (n <= 1) return 1;
var count: i32 = linearLogRecur(n / 2) + var count: i32 = linearLogRecur(n / 2) + linearLogRecur(n / 2);
linearLogRecur(n / 2);
var i: f32 = 0; var i: f32 = 0;
while (i < n) : (i += 1) { while (i < n) : (i += 1) {
count += 1; count += 1;

View file

@ -339,7 +339,7 @@
Console.WriteLine(key); Console.WriteLine(key);
} }
// 单独遍历值 value // 单独遍历值 value
foreach (String val in map.Values) { foreach (string val in map.Values) {
Console.WriteLine(val); Console.WriteLine(val);
} }
``` ```