mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-05 03:30:30 +08:00
fix(csharp): Modify method name to PascalCase, simplify new expression (#840)
* Modify method name to PascalCase(array and linked list) * Modify method name to PascalCase(backtracking) * Modify method name to PascalCase(computational complexity) * Modify method name to PascalCase(divide and conquer) * Modify method name to PascalCase(dynamic programming) * Modify method name to PascalCase(graph) * Modify method name to PascalCase(greedy) * Modify method name to PascalCase(hashing) * Modify method name to PascalCase(heap) * Modify method name to PascalCase(searching) * Modify method name to PascalCase(sorting) * Modify method name to PascalCase(stack and queue) * Modify method name to PascalCase(tree) * local check
This commit is contained in:
@@ -8,7 +8,7 @@ namespace hello_algo.chapter_dynamic_programming;
|
||||
|
||||
public class unbounded_knapsack {
|
||||
/* 完全背包:动态规划 */
|
||||
public int unboundedKnapsackDP(int[] wgt, int[] val, int cap) {
|
||||
public int UnboundedKnapsackDP(int[] wgt, int[] val, int cap) {
|
||||
int n = wgt.Length;
|
||||
// 初始化 dp 表
|
||||
int[,] dp = new int[n + 1, cap + 1];
|
||||
@@ -28,7 +28,7 @@ public class unbounded_knapsack {
|
||||
}
|
||||
|
||||
/* 完全背包:空间优化后的动态规划 */
|
||||
public int unboundedKnapsackDPComp(int[] wgt, int[] val, int cap) {
|
||||
public int UnboundedKnapsackDPComp(int[] wgt, int[] val, int cap) {
|
||||
int n = wgt.Length;
|
||||
// 初始化 dp 表
|
||||
int[] dp = new int[cap + 1];
|
||||
@@ -54,11 +54,11 @@ public class unbounded_knapsack {
|
||||
int cap = 4;
|
||||
|
||||
// 动态规划
|
||||
int res = unboundedKnapsackDP(wgt, val, cap);
|
||||
int res = UnboundedKnapsackDP(wgt, val, cap);
|
||||
Console.WriteLine("不超过背包容量的最大物品价值为 " + res);
|
||||
|
||||
// 空间优化后的动态规划
|
||||
res = unboundedKnapsackDPComp(wgt, val, cap);
|
||||
res = UnboundedKnapsackDPComp(wgt, val, cap);
|
||||
Console.WriteLine("不超过背包容量的最大物品价值为 " + res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user