Advertisement
AlvMatias

Monedas_1

Jul 31st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package Centavos;
  2. public class Centavos {
  3. public static void main(String[] args){
  4. int [] monedas={50,25,10,5,1};
  5. int [] posibilidades={0};
  6. Posibilidades p=new Posibilidades();
  7. p.hacer(monedas, posibilidades, 0, 0);
  8. System.out.printf("%d", posibilidades[0]);
  9. }
  10. }
  11.  
  12. public class Posibilidades {
  13. public void hacer(int[] monedas, int [] posibilidades, int total, int actual){
  14. if(total<56){
  15. for(int i=actual; i<5; i++){
  16. hacer(monedas, posibilidades, total+monedas[i], i);
  17. }
  18. }
  19. else if(total==56){
  20. posibilidades[0]++;
  21.  
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement