请指出以下代码段使用了何种算法public void ...
发布于 2022-03-03 14:11:07
请指出以下代码段使用了何种算法
public void func(int[] arr1, int k, int m,int[] arr2) {
arr2[0] = 0
for (int i = 1 i <= m i++) {
int min = i
for (int j = 0 j < k j++) {
if (arr1[j] <= i) {
int temp = arr2[i - arr1[j]] + 1
if (temp < min) {
min = temp
}
}
}
arr2[i] = min
}
}
public void func(int[] arr1, int k, int m,int[] arr2) {
arr2[0] = 0
for (int i = 1 i <= m i++) {
int min = i
for (int j = 0 j < k j++) {
if (arr1[j] <= i) {
int temp = arr2[i - arr1[j]] + 1
if (temp < min) {
min = temp
}
}
}
arr2[i] = min
}
}
登录后免费查看答案
关注者
0
被浏览
14