Guest User

Untitled

a guest
Apr 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1.  
  2. public class main {
  3.  
  4.     /**
  5.      * @param args
  6.      */
  7.     public static void main(String[] args) {
  8.         System.out.print("Jetzt geht's los...\n");
  9.         int s=count(300,7); // (Betrag,Münzen)
  10.         System.out.print("Ergebnis: "+s+"\n");
  11.        
  12.     }
  13.     static int count(int n,int m)
  14.     {
  15.         int c[]={1,2,5,10,20,50,100,200};
  16.         if(n==0)
  17.             return 1;
  18.         if(n<0)
  19.             return 0;
  20.         if(m<0&&n>=1)
  21.             return 0;
  22.         return count(n,m-1)+count(n-c[m],m);
  23.     }
  24.    
  25.  
  26. }
Add Comment
Please, Sign In to add comment