Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class main {
- /**
- * @param args
- */
- public static void main(String[] args) {
- System.out.print("Jetzt geht's los...\n");
- int s=count(300,7); // (Betrag,Münzen)
- System.out.print("Ergebnis: "+s+"\n");
- }
- static int count(int n,int m)
- {
- int c[]={1,2,5,10,20,50,100,200};
- if(n==0)
- return 1;
- if(n<0)
- return 0;
- if(m<0&&n>=1)
- return 0;
- return count(n,m-1)+count(n-c[m],m);
- }
- }
Add Comment
Please, Sign In to add comment