Files
Yudong Jin 2f561d3d51 feat(ko): add the Korean online edition (#2006)
* feat(ko): add the complete Korean online edition

* Use UTF-8 for Python CI output on Windows

* Remove print-book promotion from the Korean site

* fix(ko): preserve emphasis before Korean particles
2026-10-29 03:46:43 +08:00

32 lines
746 B
Zig

// File: climbing_stairs_dfs.zig
// Created Time: 2023-07-15
// Author: codingonion ([email protected])
const std = @import("std");
// 탐색
fn dfs(i: usize) i32 {
// dp[1]과 dp[2]는 이미 알고 있으므로 해당 값을 반환한다
if (i == 1 or i == 2) {
return @intCast(i);
}
// dp[i] = dp[i-1] + dp[i-2]
var count = dfs(i - 1) + dfs(i - 2);
return count;
}
// 계단 오르기: 탐색
fn climbingStairsDFS(comptime n: usize) i32 {
return dfs(n);
}
// 실행 코드
pub fn main() !void {
comptime var n: usize = 9;
var res = climbingStairsDFS(n);
std.debug.print("계단 {}칸을 오르는 방법의 수: {}\n", .{ n, res });
_ = try std.io.getStdIn().reader().readByte();
}