package OJ;
import java.util.*;
public class Bully {
/*
* 找零钱的贪心算法
* 当前有面值分别为2角5分,1角,5分,1分的硬币,请给出找n分钱的最佳方案(要求找出的硬币数目最少)
* */
public static void main(String[] args) {
int[] m = {25,10,5,1};
int n = 99;//要招99分的零钱
int[] result = new int[m.length];
result = zhaoqain(m,n);
for(int i=0;i
}
private static int[] zhaoqain(int[] m, int n) {
int[] result = new int[m.length];
for(int i=0;i
break;
result[i] = n/m[i];
n = n%m[i];
}
return result;
}
public static void sop(Object o){
System.out.print(o);
}
}