mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
Many bug fixes and improvements (#1270)
* Add Ruby and Kotlin icons Add the avatar of @curtishd * Update README * Synchronize zh-hant and zh versions. * Translate the pythontutor blocks to traditional Chinese * Fix en/mkdocs.yml * Update the landing page of the en version. * Fix the Dockerfile * Refine the en landingpage * Fix en landing page * Reset the README.md
This commit is contained in:
@ -191,11 +191,11 @@
|
||||
```ruby title=""
|
||||
# 在某執行平臺下
|
||||
def algorithm(n)
|
||||
a = 2 # 1 ns
|
||||
a = 2 # 1 ns
|
||||
a = a + 1 # 1 ns
|
||||
a = a * 2 # 10 ns
|
||||
# 迴圈 n 次
|
||||
(n...0).each do # 1 ns
|
||||
(0...n).each do # 1 ns
|
||||
puts 0 # 5 ns
|
||||
end
|
||||
end
|
||||
@ -516,7 +516,7 @@ $$
|
||||
// 演算法 C 的時間複雜度:常數階
|
||||
fn algorithm_C(n: i32) void {
|
||||
_ = n;
|
||||
for (0..1000000) |_| {
|
||||
for (0..1000000) |_| {
|
||||
std.debug.print("{}\n", .{0});
|
||||
}
|
||||
}
|
||||
@ -690,7 +690,7 @@ $$
|
||||
for (int i = 0; i < n; i++) { // +1(每輪都執行 i ++)
|
||||
printf("%d", 0); // +1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
=== "Kotlin"
|
||||
@ -1021,13 +1021,13 @@ $T(n)$ 是一次函式,說明其執行時間的增長趨勢是線性的,因
|
||||
|
||||
// +n(技巧 2)
|
||||
for(0..(5 * n + 1)) |_| {
|
||||
std.debug.print("{}\n", .{0});
|
||||
std.debug.print("{}\n", .{0});
|
||||
}
|
||||
|
||||
// +n*n(技巧 3)
|
||||
for(0..(2 * n)) |_| {
|
||||
for(0..(n + 1)) |_| {
|
||||
std.debug.print("{}\n", .{0});
|
||||
std.debug.print("{}\n", .{0});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user