背包问题理论基础完全背包:修改Java版本代码格式化问题
This commit is contained in:
parent
2793db9231
commit
581dbd64f0
|
|
@ -177,8 +177,8 @@ int main() {
|
||||||
Java:
|
Java:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
//先遍历物品,再遍历背包
|
//先遍历物品,再遍历背包
|
||||||
private static void testCompletePack(){
|
private static void testCompletePack(){
|
||||||
int[] weight = {1, 3, 4};
|
int[] weight = {1, 3, 4};
|
||||||
int[] value = {15, 20, 30};
|
int[] value = {15, 20, 30};
|
||||||
int bagWeight = 4;
|
int bagWeight = 4;
|
||||||
|
|
@ -193,10 +193,10 @@ Java:
|
||||||
for (int maxValue : dp){
|
for (int maxValue : dp){
|
||||||
System.out.println(maxValue + " ");
|
System.out.println(maxValue + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//先遍历背包,再遍历物品
|
//先遍历背包,再遍历物品
|
||||||
private static void testCompletePackAnotherWay(){
|
private static void testCompletePackAnotherWay(){
|
||||||
int[] weight = {1, 3, 4};
|
int[] weight = {1, 3, 4};
|
||||||
int[] value = {15, 20, 30};
|
int[] value = {15, 20, 30};
|
||||||
int bagWeight = 4;
|
int bagWeight = 4;
|
||||||
|
|
@ -211,7 +211,7 @@ Java:
|
||||||
for (int maxValue : dp){
|
for (int maxValue : dp){
|
||||||
System.out.println(maxValue + " ");
|
System.out.println(maxValue + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue