mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 08:46:28 +08:00
fix: Polishing code format on linearLogRecur, convert String type to string (#841)
This commit is contained in:
parent
2bba70fd87
commit
e03022d5fb
7 changed files with 8 additions and 16 deletions
|
@ -134,8 +134,7 @@ public class time_complexity {
|
|||
/* 线性对数阶 */
|
||||
static int LinearLogRecur(float n) {
|
||||
if (n <= 1) return 1;
|
||||
int count = LinearLogRecur(n / 2) +
|
||||
LinearLogRecur(n / 2);
|
||||
int count = LinearLogRecur(n / 2) + LinearLogRecur(n / 2);
|
||||
for (int i = 0; i < n; i++) {
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,8 @@ public class worst_best_time_complexity {
|
|||
|
||||
// 随机打乱数组元素
|
||||
for (int i = 0; i < nums.Length; i++) {
|
||||
var index = new Random().Next(i, nums.Length);
|
||||
var tmp = nums[i];
|
||||
var ran = nums[index];
|
||||
nums[i] = ran;
|
||||
nums[index] = tmp;
|
||||
int index = new Random().Next(i, nums.Length);
|
||||
(nums[i], nums[index]) = (nums[index], nums[i]);
|
||||
}
|
||||
return nums;
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ func linearLogRecur(n float64) int {
|
|||
if n <= 1 {
|
||||
return 1
|
||||
}
|
||||
count := linearLogRecur(n/2) +
|
||||
linearLogRecur(n/2)
|
||||
count := linearLogRecur(n / 2) + linearLogRecur(n / 2)
|
||||
for i := 0.0; i < n; i++ {
|
||||
count++
|
||||
}
|
||||
|
|
|
@ -107,8 +107,7 @@ public class time_complexity {
|
|||
static int linearLogRecur(float n) {
|
||||
if (n <= 1)
|
||||
return 1;
|
||||
int count = linearLogRecur(n / 2) +
|
||||
linearLogRecur(n / 2);
|
||||
int count = linearLogRecur(n / 2) + linearLogRecur(n / 2);
|
||||
for (int i = 0; i < n; i++) {
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -111,8 +111,7 @@ fn linear_log_recur(n: f32) -> i32 {
|
|||
if n <= 1.0 {
|
||||
return 1;
|
||||
}
|
||||
let mut count = linear_log_recur(n / 2.0) +
|
||||
linear_log_recur(n / 2.0);
|
||||
let mut count = linear_log_recur(n / 2.0) + linear_log_recur(n / 2.0);
|
||||
for _ in 0 ..n as i32 {
|
||||
count += 1;
|
||||
}
|
||||
|
|
|
@ -115,8 +115,7 @@ fn logRecur(n: f32) i32 {
|
|||
// 线性对数阶
|
||||
fn linearLogRecur(n: f32) i32 {
|
||||
if (n <= 1) return 1;
|
||||
var count: i32 = linearLogRecur(n / 2) +
|
||||
linearLogRecur(n / 2);
|
||||
var count: i32 = linearLogRecur(n / 2) + linearLogRecur(n / 2);
|
||||
var i: f32 = 0;
|
||||
while (i < n) : (i += 1) {
|
||||
count += 1;
|
||||
|
|
|
@ -339,7 +339,7 @@
|
|||
Console.WriteLine(key);
|
||||
}
|
||||
// 单独遍历值 value
|
||||
foreach (String val in map.Values) {
|
||||
foreach (string val in map.Values) {
|
||||
Console.WriteLine(val);
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue